@Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("enabled")) { updateEnabledState(); } else if (evt.getPropertyName() == DrawingEditor.ACTIVE_VIEW_PROPERTY) { if (activeView != null) { activeView.removePropertyChangeListener(eventHandler); activeView = null; } if (evt.getNewValue() != null) { activeView = ((DrawingView) evt.getNewValue()); activeView.addPropertyChangeListener(eventHandler); updateEnabledState(); } updateViewState(); } }
@Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName() == DrawingEditor.ACTIVE_VIEW_PROPERTY) { if (activeView != null) { activeView.removeFigureSelectionListener(this); activeView.removePropertyChangeListener(this); } if (evt.getNewValue() != null) { activeView = ((DrawingView) evt.getNewValue()); activeView.addFigureSelectionListener(this); activeView.addPropertyChangeListener(this); } updateEnabledState(); } else if (evt.getPropertyName().equals("enabled")) { updateEnabledState(); } }
/** Registers the event handler from the drawing editor and the * active drawing view. */ private void registerEventHandler() { if (specificView != null) { specificView.addPropertyChangeListener(eventHandler); } else { if (editor != null) { editor.addPropertyChangeListener(new WeakPropertyChangeListener(eventHandler)); if (activeView != null) { activeView.removePropertyChangeListener(eventHandler); } activeView = editor.getActiveView(); if (activeView != null) { activeView.addPropertyChangeListener(eventHandler); } } } } }
public SelectionComponentDisplayer(DrawingEditor editor, JComponent component) { this.editor = editor; this.weakRef = new WeakReference<JComponent>(component); if (editor.getActiveView() != null) { view = editor.getActiveView(); view.addPropertyChangeListener(this); view.addFigureSelectionListener(this); } editor.addPropertyChangeListener(this); updateVisibility(); }
@Override public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (name == DrawingEditor.ACTIVE_VIEW_PROPERTY) { if (view != null) { view.removePropertyChangeListener(this); view.removeFigureSelectionListener(this); } view = (DrawingView) evt.getNewValue(); if (view != null) { view.addPropertyChangeListener(this); view.addFigureSelectionListener(this); } updateVisibility(); } else if (name == DrawingEditor.TOOL_PROPERTY) { updateVisibility(); } }
/** * Creates a button which toggles between two GridConstrainer for * a DrawingView. */ public static AbstractButton createToggleGridButton(final DrawingView view) { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); final JToggleButton toggleButton; toggleButton = new JToggleButton(); labels.configureToolBarButton(toggleButton, "view.toggleGrid"); toggleButton.setFocusable(false); toggleButton.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { view.setConstrainerVisible(toggleButton.isSelected()); //view.getComponent().repaint(); } }); view.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { // String constants are interned if (evt.getPropertyName() == DrawingView.CONSTRAINER_VISIBLE_PROPERTY) { toggleButton.setSelected(view.isConstrainerVisible()); } } }); return toggleButton; }
public DrawingComponentRepainter(DrawingEditor editor, JComponent component) { this.editor = editor; this.component = component; if (editor != null) { if (editor.getActiveView() != null) { DrawingView view = editor.getActiveView(); view.addPropertyChangeListener(this); if (view.getDrawing() != null) { view.getDrawing().addFigureListener(this); } } editor.addPropertyChangeListener(this); } }
view.addPropertyChangeListener(this); if (view.getDrawing() != null) { view.getDrawing().addFigureListener(this);
/** Registers the event handler from the drawing editor and the * active drawing view. */ private void registerEventHandler() { if (editor != null) { editor.addPropertyChangeListener(new WeakPropertyChangeListener(eventHandler)); if (activeView != null) { activeView.removeFigureSelectionListener(eventHandler); activeView.removePropertyChangeListener(eventHandler); } activeView = editor.getActiveView(); if (activeView != null) { activeView.addFigureSelectionListener(eventHandler); activeView.addPropertyChangeListener(eventHandler); } } } }
view.addPropertyChangeListener(this); view.addFigureSelectionListener(this); if (view.getDrawing() != null) {
public SelectionComponentRepainter(DrawingEditor editor, JComponent component) { this.editor = editor; this.component = component; if (editor != null) { if (editor.getActiveView() != null) { DrawingView view = editor.getActiveView(); view.addPropertyChangeListener(this); view.addFigureSelectionListener(this); if (view.getDrawing() != null) { view.getDrawing().addFigureListener(this); } } editor.addPropertyChangeListener(this); } }
view.addPropertyChangeListener(new PropertyChangeListener() {
public static AbstractButton createZoomButton(final DrawingView view, double[] factors) { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); final JPopupButton zoomPopupButton = new JPopupButton(); labels.configureToolBarButton(zoomPopupButton, "view.zoomFactor"); zoomPopupButton.setFocusable(false); zoomPopupButton.setText((int) (view.getScaleFactor() * 100) + " %"); view.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { // String constants are interned if (evt.getPropertyName() == "scaleFactor") { zoomPopupButton.setText((int) (view.getScaleFactor() * 100) + " %"); } } }); for (int i = 0; i < factors.length; i++) { zoomPopupButton.add( new ZoomAction(view, factors[i], zoomPopupButton) { @Override public void actionPerformed(java.awt.event.ActionEvent e) { super.actionPerformed(e); zoomPopupButton.setText((int) (view.getScaleFactor() * 100) + " %"); } }); } //zoomPopupButton.setPreferredSize(new Dimension(16,16)); zoomPopupButton.setFocusable(false); return zoomPopupButton; }
protected void updateActiveView() { DrawingView newValue = (view != null) ? // view : // ((editor != null && editor.getActiveView() != null) ? // editor.getActiveView() : null); DrawingView oldValue = activeView; if (activeView != null) { activeView.removePropertyChangeListener(eventHandler); activeView.removeFigureSelectionListener(eventHandler); if (figuresOfInterest != null) { for (Figure f : figuresOfInterest) { f.removeFigureListener(eventHandler); } } } activeView = newValue; if (activeView != null) { activeView.addPropertyChangeListener(eventHandler); activeView.addFigureSelectionListener(eventHandler); figuresOfInterest = getEditedFigures(); for (Figure f : figuresOfInterest) { f.addFigureListener(eventHandler); } } attributeRestoreData = null; updateAttributeEditor(); }