Logo Search packages:      
Sourcecode: wims version File versions

fr::ove::openmath::jome::ctrlview::bidim::Display::Display ( GraphicContext  graphicContext  )  [inline]

The constructor.

Parameters:
graphicContext the graphic context of the display.

Definition at line 150 of file Display.java.

References fr::ove::openmath::jome::ctrlview::bidim::DisplayLayout::deselectDisplay(), dragNDrop, fr::ove::openmath::jome::ctrlview::bidim::GraphicContext::getBackgroundColor(), fr::ove::openmath::jome::ctrlview::bidim::GraphicContext::getFont(), fr::ove::openmath::jome::ctrlview::bidim::GraphicContext::getForegroundColor(), iconify(), isSelected(), moveSelectedDisplays(), fr::ove::openmath::jome::ctrlview::bidim::DisplayLayout::selectDisplay(), setFont(), and uniconify().

                                                  {
        super();
        
        this.graphicContext = new GraphicContext(graphicContext);
        setFont(graphicContext.getFont());
        setForeground(graphicContext.getForegroundColor());
        setBackground(graphicContext.getBackgroundColor());
        
        addMouseListener( 
            new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    SelectionEvent selEvt = new SelectionEvent(Display.this);
                    if (e.isControlDown()) {
                        if (!isSelected) {
                            DisplayLayout displayLayout = (DisplayLayout) getLayout();
                            
                            if (displayLayout instanceof OneFormulaLayout) {
                                Display formulaDisplay = (Display) getComponent(0);
                                if (formulaDisplay.isSelected())
                                    displayLayout.deselectDisplay();
                                else {
                                    displayLayout.selectDisplay();
                                    setCursor(new Cursor(Cursor.HAND_CURSOR));
                                }
                            }
                            else {
                                displayLayout.selectDisplay();
                                setCursor(new Cursor(Cursor.HAND_CURSOR));
                            }

                            repaint();
                        }
                        else {
                            ((DisplayLayout) getLayout()).deselectDisplay();
                            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

                            repaint();
                        }
                    }
                    else if (e.isShiftDown())
                        iconify();
                    else if (e.isAltDown())
                        uniconify();
                }
                
                public void mouseEntered(MouseEvent e) {
                    if (isSelected) 
                        setCursor(new Cursor(Cursor.HAND_CURSOR));
                    else
                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                }
            
                public void mouseReleased(MouseEvent e) {
                    int mouseX = e.getX();
                    
                    if (dragNDrop) {
                        moveSelectedDisplays(mouseX);
                        dragNDrop = false;
                        repaint();
                    }
                }

            }
        );
        
        addMouseMotionListener(
            new MouseMotionAdapter() {
                public void mouseDragged(MouseEvent e) {
                    if (isSelected) {
                        dragNDrop = true;
                        setCursor(new Cursor(Cursor.MOVE_CURSOR));
                    }
                }
                
                public void mouseMoved(MouseEvent e) {
                    if (isSelected) 
                        setCursor(new Cursor(Cursor.HAND_CURSOR));
                    else
                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                }
            }
        );
      }


Generated by  Doxygen 1.6.0   Back to index