org.eclipse.draw2d.ImageFigure Java Examples
The following examples show how to use
org.eclipse.draw2d.ImageFigure.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FunnyStyleSupport.java From ermaster-b with Apache License 2.0 | 6 votes |
public void addIndex(IndexFigure indexFigure, String name, boolean isFirst) { ImageFigure image = new ImageFigure(); image.setBorder(new MarginBorder(new Insets(0, 0, 0, 19))); image.setImage(Activator.getImage(ImageKey.BLANK_WHITE)); image.setOpaque(true); indexFigure.add(image); // Label filler = new Label(); // filler.setBorder(new MarginBorder(new Insets(0, 0, 0, 16))); // filler.setBorder(new MarginBorder(new Insets(1, 4, 0, 16))); // indexFigure.add(filler); StringBuilder text = new StringBuilder(); text.append(name); Label label = this.createColumnLabel(); label.setBorder(new MarginBorder(new Insets(1, 0, 0, 4))); label.setForegroundColor(ColorConstants.black); label.setText(text.toString()); indexFigure.add(label); }
Example #2
Source File: UpdateSizePoolSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void showSelectionForAddRight(double zoom) { if(sourceFigure == null){ if(poolEditPart == null){ poolEditPart = findPoolEditPart(getHost()); if(poolEditPart == null) { return ; } } sourceFigure = poolEditPart.getFigure() ; } Rectangle ref = sourceFigure.getBounds(); IFigure f = new ImageFigure(Pics.getImage(PicsConstants.plusBlack)); f.setSize(20, 20); f.setLocation(ref.getRight().getCopy().translate(10, -20)); f.getBounds().performScale(zoom) ; f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.ADD_RIGHT)); layer.add(f); figures.put(UpdateSizePoolSelectionEditPolicy.ADD_RIGHT,f); }
Example #3
Source File: UpdateSizePoolSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void showSelectionForAddBottom(double zoom) { if(sourceFigure == null){ if(poolEditPart == null){ poolEditPart = findPoolEditPart(getHost()); if(poolEditPart == null) { return ; } } sourceFigure = poolEditPart.getFigure() ; } Rectangle ref = sourceFigure.getBounds(); IFigure f = new ImageFigure(Pics.getImage(PicsConstants.plusBlack)); f.setSize(20, 20); f.setLocation(ref.getBottom().getCopy().translate(20, 0)); f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.ADD_BOTTOM)); f.getBounds().performScale(zoom); layer.add(f); figures.put(UpdateSizePoolSelectionEditPolicy.ADD_BOTTOM,f); }
Example #4
Source File: UpdateSizeLaneSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void showSelectionForRemoveBottom() { if(sourceFigure == null){ if(laneEditPart == null){ laneEditPart = findLaneEditPart(getHost()); if(laneEditPart == null) { return ; } } sourceFigure = laneEditPart.getFigure() ; } final Rectangle ref = sourceFigure.getBounds().getCopy(); FiguresHelper.translateToAbsolute(sourceFigure, ref); final IFigure f = new ImageFigure(Pics.getImage(PicsConstants.minusBlack)); f.setSize(20, 20); f.setLocation(ref.getBottom().translate(0, -20)); f.addMouseListener(new MouseListenerForSpan(UpdateSizeLaneSelectionEditPolicy.REMOVE_BOTTOM)); layer.add(f); figures.add(f); }
Example #5
Source File: UpdateSizeLaneSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void showSelectionForAddBottom() { if(sourceFigure == null){ if(laneEditPart == null){ laneEditPart = findLaneEditPart(getHost()); if(laneEditPart == null) { return ; } } sourceFigure = laneEditPart.getFigure() ; } final Rectangle ref = sourceFigure.getBounds().getCopy(); FiguresHelper.translateToAbsolute(sourceFigure, ref); final IFigure f = new ImageFigure(Pics.getImage(PicsConstants.plusBlack)); f.setSize(20, 20); f.setLocation(ref.getBottom().translate(0, 1)); f.addMouseListener(new MouseListenerForSpan(UpdateSizeLaneSelectionEditPolicy.ADD_BOTTOM)); layer.add(f); figures.add(f); }
Example #6
Source File: UpdateSizePoolSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void showSelectionForRemoveBottom(double zoom) { if(sourceFigure == null){ if(poolEditPart == null){ poolEditPart = findPoolEditPart(getHost()); if(poolEditPart == null) { return ; } } sourceFigure = poolEditPart.getFigure() ; } Rectangle ref = sourceFigure.getBounds(); IFigure f = new ImageFigure(Pics.getImage(PicsConstants.minusBlack)); f.setSize(20, 20); f.setLocation(ref.getBottom().getCopy().translate(20, -20)); f.getBounds().performScale(zoom); f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.REMOVE_BOTTOM)); layer.add(f); figures.put(UpdateSizePoolSelectionEditPolicy.REMOVE_BOTTOM,f); }
Example #7
Source File: UpdateSizePoolSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * */ private void showSelectionForRemoveRight(double zoom) { if(sourceFigure == null){ if(poolEditPart == null){ poolEditPart = findPoolEditPart(getHost()); if(poolEditPart == null) { return ; } } sourceFigure = poolEditPart.getFigure() ; } Rectangle ref = sourceFigure.getBounds(); IFigure f = new ImageFigure(Pics.getImage(PicsConstants.minusBlack)); f.setSize(20, 20); f.setLocation(ref.getLeft().getCopy().translate(-25, -10)); f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.REMOVE_RIGHT)); f.getBounds().performScale(zoom); layer.add(f); figures.put(UpdateSizePoolSelectionEditPolicy.REMOVE_RIGHT,f); }
Example #8
Source File: ExtendedUIAdapter.java From birt with Eclipse Public License 1.0 | 6 votes |
public void disposeFigure( ExtendedItemHandle handle, IFigure figure ) { switch( extensionType ) { case FIGURE_EXTENSION_TYPE: figureExtension.disposeFigure(handle, figure); break; case IMAGE_EXTENSION_TYPE: imageExtension.disposeImage( handle, ((ImageFigure)figure).getImage() ); break; case LABEL_EXTENSION_TYPE: // no action needed break; } }
Example #9
Source File: ExtendedUIAdapter.java From birt with Eclipse Public License 1.0 | 6 votes |
public void updateFigure( ExtendedItemHandle handle, IFigure figure ) { switch( extensionType ) { case FIGURE_EXTENSION_TYPE: figureExtension.updateFigure(handle, figure); break; case IMAGE_EXTENSION_TYPE: ImageFigure imageFigure = (ImageFigure)figure; Image newImage = imageExtension.getImage( handle ); Image oldImage = imageFigure.getImage(); if ( newImage != oldImage ) { imageFigure.setImage(newImage); imageExtension.disposeImage( handle, oldImage ); } break; case LABEL_EXTENSION_TYPE: ((Label)figure).setText(labelExtension.getLabel( handle )); break; } }
Example #10
Source File: ExtendedUIAdapter.java From birt with Eclipse Public License 1.0 | 6 votes |
public IFigure createFigure( ExtendedItemHandle handle ) { switch( extensionType ) { case FIGURE_EXTENSION_TYPE: return figureExtension.createFigure(handle); case IMAGE_EXTENSION_TYPE: return new ImageFigure(imageExtension.getImage( handle )); case LABEL_EXTENSION_TYPE: return new Label(labelExtension.getLabel( handle )); default: return null; } }
Example #11
Source File: FunnyStyleSupport.java From erflute with Apache License 2.0 | 6 votes |
@Override public void addIndex(IndexFigure indexFigure, String name, boolean isFirst) { final ImageFigure image = new ImageFigure(); image.setBorder(new MarginBorder(new Insets(0, 0, 0, 19))); image.setImage(Activator.getImage(ImageKey.BLANK_WHITE)); image.setOpaque(true); indexFigure.add(image); final StringBuilder text = new StringBuilder(); text.append(name); final Label label = createColumnLabel(); label.setBorder(new MarginBorder(new Insets(1, 0, 0, 4))); label.setForegroundColor(ColorConstants.black); label.setText(text.toString()); indexFigure.add(label); }
Example #12
Source File: FunnyStyleSupport.java From erflute with Apache License 2.0 | 6 votes |
@Override public void addColumnGroup(GroupColumnFigure columnFigure, int viewMode, String name, boolean isAdded, boolean isUpdated, boolean isRemoved) { columnFigure.setBorder(new MarginBorder(new Insets(1, 0, 1, 0))); final ImageFigure image = new ImageFigure(); image.setBorder(new MarginBorder(new Insets(0, 4, 0, 7))); image.setImage(Activator.getImage(ImageKey.GROUP)); columnFigure.add(image); final StringBuilder text = new StringBuilder(); text.append(name); text.append(" (GROUP)"); setColumnFigureColor(columnFigure, false, false, isAdded, isUpdated, isRemoved); final Label label = createColumnLabel(); label.setForegroundColor(ColorConstants.black); label.setLabelAlignment(PositionConstants.RIGHT); label.setBorder(new MarginBorder(new Insets(1, 3, 0, 4))); label.setText(text.toString()); columnFigure.add(label); }
Example #13
Source File: DropDownMenuFigure.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public DropDownMenuFigure(final ImageFigure image,IFigure parent, IFigure layer, String tooltip){ super(image); setToolTip(new Label(tooltip)); this.parent = parent ; this.layer = layer; location = parent.getBounds().getLocation().getCopy(); listeners = new ArrayList<Listener>() ; ButtonModel bModel = createDefaultModel(); bModel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { switchVisible(); fireVisibilityChanged() ; } }); setModel(bModel); }
Example #14
Source File: ImageTest.java From ermaster-b with Apache License 2.0 | 6 votes |
private static Figure createContents() { Figure contents = new Figure(); XYLayout layout = new XYLayout(); contents.setLayoutManager(layout); Button button = new Button("Hello World"); layout.setConstraint(button, new Rectangle(0, 0, -1, -1)); contents.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionevent) { setBrightness(); } }); String path = "C:\\Users\\Public\\Pictures\\Sample Pictures\\Oryx Antelope.jpg"; image = new Image(Display.getDefault(), path); imageFigure = new ImageFigure(image); layout.setConstraint(imageFigure, new Rectangle(0, 30, -1, -1)); contents.add(imageFigure); return contents; }
Example #15
Source File: LifeCycleWidget.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private IFigure createLifecycleFigure() { IFigure figure = new ImageFigure(imageLifeCycle); addEvent(figure, ConnectorEvent.ON_ENTER.toString(), new org.eclipse.draw2d.geometry.Point(45, 40), 10); EventCircle defaultEvent = addEvent(figure, ConnectorEvent.ON_FINISH.toString(), new org.eclipse.draw2d.geometry.Point(226, 40), 10); if(event == null){ defaultEvent.select(); } return figure; }
Example #16
Source File: FunnyStyleSupport.java From ermaster-b with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void initTitleBar(Figure top) { top.setLayoutManager(new BorderLayout()); FlowLayout layout = new FlowLayout(); layout.setStretchMinorAxis(true); Figure title = new Figure(); top.add(title, BorderLayout.TOP); title.setLayoutManager(layout); if (new BigDecimal("1.5").equals(getSettings().getTitleFontEm())) { title.setBorder(new MarginBorder(new Insets(2, 2, 2, 2))); } else { title.setBorder(new MarginBorder(new Insets(4, 4, 4, 4))); } ImageFigure image = new ImageFigure(); image.setBorder(new MarginBorder(new Insets(0, 0, 0, 0))); image.setImage(Activator.getImage(this.getTableFigure().getImageKey())); title.add(image); this.nameLabel = new Label(); this.nameLabel.setBorder(new MarginBorder(new Insets(0, 0, 0, 20))); title.add(this.nameLabel); Figure separater = new Figure(); separater.setSize(-1, 1); separater.setBackgroundColor(ColorConstants.black); separater.setOpaque(true); top.add(separater, BorderLayout.BOTTOM); }
Example #17
Source File: FunnyStyleSupport.java From ermaster-b with Apache License 2.0 | 5 votes |
@Override public void addColumnGroup(GroupColumnFigure columnFigure, int viewMode, String name, boolean isAdded, boolean isUpdated, boolean isRemoved) { columnFigure.setBorder(new MarginBorder(new Insets(1, 0, 1, 0))); ImageFigure image = new ImageFigure(); image.setBorder(new MarginBorder(new Insets(0, 4, 0, 7))); image.setImage(Activator.getImage(ImageKey.GROUP)); columnFigure.add(image); // Label filler = new Label(); // filler.setBorder(new MarginBorder(new Insets(0, 0, 0, 16))); // filler.setBorder(new MarginBorder(new Insets(0, 0, 0, 6))); // columnFigure.add(filler); // filler = new Label(); // filler.setBorder(new MarginBorder(new Insets(0, 0, 0, 16))); // columnFigure.add(filler); StringBuilder text = new StringBuilder(); text.append(name); text.append(" (GROUP)"); this.setColumnFigureColor(columnFigure, false, false, isAdded, isUpdated, isRemoved); Label label = this.createColumnLabel(); label.setForegroundColor(ColorConstants.black); label.setLabelAlignment(PositionConstants.RIGHT); label.setBorder(new MarginBorder(new Insets(1, 3, 0, 4))); label.setText(text.toString()); columnFigure.add(label); }
Example #18
Source File: AbstractSwitchLaneSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @param zoom * */ private void showSelectionForAddBottom(double zoom) { if (!isOnBottom()) { IFigure f = new ImageFigure(Pics.getImage(PicsConstants.arrowDown)); f.setSize(20, 20); sourceFigure = getHostFigure() ; Rectangle bounds = sourceFigure.getBounds().getCopy(); //get the absolute coordinate of bounds sourceFigure.translateToAbsolute(bounds); IFigure parentFigure = sourceFigure.getParent(); while( parentFigure != null ) { if(parentFigure instanceof Viewport) { Viewport viewport = (Viewport)parentFigure; bounds.translate( viewport.getHorizontalRangeModel().getValue(), viewport.getVerticalRangeModel().getValue()); parentFigure = parentFigure.getParent(); } else { parentFigure = parentFigure.getParent(); } } Point location =new Point(bounds.getBottomLeft().x+20,bounds.getBottomLeft().y) ; f.setLocation(location); f.addMouseListener(new MouseListenerForSpan(AbstractSwitchLaneSelectionEditPolicy.ADD_BOTTOM)); getLayer(LayerConstants.HANDLE_LAYER).add(f); figures.add(f); } }
Example #19
Source File: SwitchPoolSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * */ private void showSelectionForAddTop() { if (!isOnTop()) { IFigure f = new ImageFigure(Pics.getImage(PicsConstants.arrowUp)); f.setParent(getHostFigure()); f.setSize(20, 20); sourceFigure = getHostFigure() ; Rectangle bounds = sourceFigure.getBounds().getCopy(); //get the absolute coordinate of bounds sourceFigure.translateToAbsolute(bounds); IFigure parentFigure = sourceFigure.getParent(); while( parentFigure != null ) { if(parentFigure instanceof Viewport) { Viewport viewport = (Viewport)parentFigure; bounds.translate( viewport.getHorizontalRangeModel().getValue(), viewport.getVerticalRangeModel().getValue()); parentFigure = parentFigure.getParent(); } else { parentFigure = parentFigure.getParent(); } } f.setLocation(new Point(bounds.getTopLeft().x,bounds.getTop().y-20)); f.addMouseListener(new MouseListenerForSpan(AbstractSwitchLaneSelectionEditPolicy.ADD_TOP)); layer.add(f); figures.add(f); } }
Example #20
Source File: SwitchPoolSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * */ private void showSelectionForAddBottom() { if (!isOnBottom()) { IFigure f = new ImageFigure(Pics.getImage(PicsConstants.arrowDown)); f.setSize(20, 20); sourceFigure = getHostFigure() ; Rectangle bounds = sourceFigure.getBounds().getCopy(); //get the absolute coordinate of bounds sourceFigure.translateToAbsolute(bounds); IFigure parentFigure = sourceFigure.getParent(); while( parentFigure != null ) { if(parentFigure instanceof Viewport) { Viewport viewport = (Viewport)parentFigure; bounds.translate( viewport.getHorizontalRangeModel().getValue(), viewport.getVerticalRangeModel().getValue()); parentFigure = parentFigure.getParent(); } else { parentFigure = parentFigure.getParent(); } } f.setLocation(new Point(bounds.getBottomLeft().x,bounds.getBottom().y)); f.addMouseListener(new MouseListenerForSpan(AbstractSwitchLaneSelectionEditPolicy.ADD_BOTTOM)); layer.add(f); figures.add(f); } }
Example #21
Source File: AbstractSwitchLaneSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @param zoom * */ private void showSelectionForAddTop(double zoom) { if (!isOnTop()) { IFigure f = new ImageFigure(Pics.getImage(PicsConstants.arrowUp)); f.setParent(getHostFigure()); f.setSize(20, 20); sourceFigure = getHostFigure() ; Rectangle bounds = sourceFigure.getBounds().getCopy(); //get the absolute coordinate of bounds sourceFigure.translateToAbsolute(bounds); IFigure parentFigure = sourceFigure.getParent(); while( parentFigure != null ) { if(parentFigure instanceof Viewport) { Viewport viewport = (Viewport)parentFigure; bounds.translate( viewport.getHorizontalRangeModel().getValue(), viewport.getVerticalRangeModel().getValue()); parentFigure = parentFigure.getParent(); } else { parentFigure = parentFigure.getParent(); } } Point location = new Point(bounds.getTopLeft().x+20,bounds.getTopLeft().y-20) ; f.setLocation(location); f.addMouseListener(new MouseListenerForSpan(AbstractSwitchLaneSelectionEditPolicy.ADD_TOP)); getLayer(LayerConstants.HANDLE_LAYER).add(f); figures.add(f); } }
Example #22
Source File: TreeMapper.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @return a newly created figure to alert the end-user of an inconsistency in the widget */ private IFigure createWarningFigure() { Image image = Display.getDefault().getSystemImage(SWT.ICON_WARNING); ImageFigure res = new ImageFigure(image); res.setPreferredSize(10, 10); Label label = new Label(Messages.widgetInconsistency); res.setToolTip(label); return res; }
Example #23
Source File: UpdateSizeLaneSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void showSelectionForRemoveRight(final double zoom) { final IFigure poolFigure = getPoolEditPart().getFigure(); final Rectangle ref = poolFigure.getBounds(); final IFigure f = new ImageFigure(Pics.getImage(PicsConstants.minusBlack)); f.setSize(20, 20); f.setLocation(ref.getLeft().translate(-25, -10)); f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.REMOVE_RIGHT)); f.getBounds().performScale(zoom); layer.add(f); figures.add(f); }
Example #24
Source File: UpdateSizeLaneSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void showSelectionForAddRight(final double zoom) { final IFigure poolFigure = getPoolEditPart().getFigure(); final Rectangle ref = poolFigure.getBounds(); final IFigure f = new ImageFigure(Pics.getImage(PicsConstants.plusBlack)); f.setSize(20, 20); f.setLocation(ref.getRight().translate(10, -20)); f.getBounds().performScale(zoom) ; f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.ADD_RIGHT)); layer.add(f); figures.add(f); }
Example #25
Source File: FunnyStyleSupport.java From erflute with Apache License 2.0 | 5 votes |
@Override public void initTitleBar(Figure top) { top.setLayoutManager(new BorderLayout()); final FlowLayout layout = new FlowLayout(); layout.setStretchMinorAxis(true); final Figure title = new Figure(); top.add(title, BorderLayout.TOP); title.setLayoutManager(layout); title.setBorder(new MarginBorder(new Insets(2, 2, 2, 2))); final ImageFigure image = new ImageFigure(); image.setBorder(new MarginBorder(new Insets(0, 0, 0, 0))); image.setImage(Activator.getImage(getTableFigure().getImageKey())); title.add(image); this.nameLabel = new Label(); nameLabel.setBorder(new MarginBorder(new Insets(0, 0, 0, 20))); title.add(nameLabel); final Figure separater = new Figure(); separater.setSize(-1, 1); separater.setBackgroundColor(ColorConstants.black); separater.setOpaque(true); top.add(separater, BorderLayout.BOTTOM); }
Example #26
Source File: SubStateDecorator.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override protected IFigure getToolTipFigure(EObject element) { if (element instanceof State) { Diagram diagram = getTooltipDiagramToRender((State) element); if (diagram != null) { Image renderImage = renderImage(diagram); return new ImageFigure(renderImage); } } return null; }
Example #27
Source File: ImageTest.java From ermasterr with Apache License 2.0 | 5 votes |
private static Figure createContents() { final Figure contents = new Figure(); final XYLayout layout = new XYLayout(); contents.setLayoutManager(layout); final Button button = new Button("Hello World"); layout.setConstraint(button, new Rectangle(0, 0, -1, -1)); contents.add(button); button.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent actionevent) { setBrightness(); } }); final String path = "C:\\Users\\Public\\Pictures\\Sample Pictures\\Oryx Antelope.jpg"; image = new Image(Display.getDefault(), path); imageFigure = new ImageFigure(image); layout.setConstraint(imageFigure, new Rectangle(0, 30, -1, -1)); contents.add(imageFigure); return contents; }
Example #28
Source File: FunnyStyleSupport.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void initTitleBar(final Figure top) { top.setLayoutManager(new BorderLayout()); final Figure title = new Figure(); top.add(title, BorderLayout.TOP); final FlowLayout titleLayout = new FlowLayout(); titleLayout.setMinorAlignment(OrderedLayout.ALIGN_CENTER); title.setLayoutManager(titleLayout); final ImageFigure image = new ImageFigure(); image.setBorder(new MarginBorder(new Insets(5, 10, 5, 2))); image.setImage(ERDiagramActivator.getImage(getTableFigure().getImageKey())); title.add(image); nameLabel = new Label(); nameLabel.setBorder(new MarginBorder(new Insets(5, 0, 5, 20))); title.add(nameLabel); final Figure separater = new Figure(); separater.setSize(-1, 1); separater.setBackgroundColor(ColorConstants.black); separater.setOpaque(true); top.add(separater, BorderLayout.BOTTOM); }
Example #29
Source File: GrayableButton.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override public void setEnabled(boolean value) { super.setEnabled(value); if (value) setContents(new ImageFigure(image)); else setContents(new ImageFigure(grayImage)); }
Example #30
Source File: XYGraphToolbar.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Create buttons enumerated in <code>ZoomType</code> * * @param flags * Bitwise 'or' of flags * @see XYGraphFlags#COMBINED_ZOOM * @see XYGraphFlags#SEPARATE_ZOOM */ private void createZoomButtons(final int flags) { for (final ZoomType zoomType : ZoomType.values()) { if (!zoomType.useWithFlags(flags)) continue; final ImageFigure imageFigure = new ImageFigure(zoomType.getIconImage()); final Label tip = new Label(zoomType.getDescription()); final ToggleButton button = new ToggleButton(imageFigure); button.setBackgroundColor(ColorConstants.button); button.setOpaque(true); final ToggleModel model = new ToggleModel(); model.addChangeListener(new ChangeListener() { public void handleStateChanged(ChangeEvent event) { if (event.getPropertyName().equals("selected") && button.isSelected()) { xyGraph.setZoomType(zoomType); } } }); button.setModel(model); zoomButtonModelMap.put(zoomType, model); button.setToolTip(tip); addButton(button); zoomGroup.add(model); if (zoomType == ZoomType.NONE) zoomGroup.setDefault(model); } xyGraph.addPropertyChangeListener(IXYGraph.PROPERTY_ZOOMTYPE, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { zoomGroup.setSelected(zoomButtonModelMap.get(evt.getNewValue())); } }); }