public ChartFigure(final Chart chart, final ActionListener deleteListener) { setPreferredSize(-1, 200); setBackgroundColor(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); setOutline(false); BorderLayout topLayout = new BorderLayout(); setLayoutManager(topLayout); titleFigure = new DirectionalShape(); chartNameLabel = new DirectionalIconLabel(StackedchartsImages.getImage( StackedchartsImages.DESC_CHART)); titleFigure.add(chartNameLabel); final Button button = new Button(StackedchartsImages.getImage( StackedchartsImages.DESC_DELETE)); button.setToolTip(new Label("Remove this chart from the chart set")); button.addActionListener(deleteListener); titleFigure.add(button); add(titleFigure); chartFigure = new JFreeChartFigure(chart); add(chartFigure, BorderLayout.CENTER); }
MethodWidget(IMethod method) { setLayoutManager(new FlowLayout()); button = new Button(shortSig(method)); button.setToolTip(new Label(longSig(method))); button.setForegroundColor(ColorConstants.black); FontManager.setFont(button, PandionJConstants.BUTTON_FONT_SIZE); button.setEnabled(methodsEnabled); add(button); resultLabel = new Label(); resultLabel.setForegroundColor(ColorConstants.black); add(resultLabel); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { invoke(model, method, resultLabel); } }); }
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; }
private void addSnapshotButton() { Button snapShotButton = new Button(XYGraphMediaFactory.getInstance().getImage("images/camera.gif")); snapShotButton.setToolTip(new Label("Save Snapshot to PNG file")); addButton(snapShotButton); snapShotButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event) { // Have valid name, so get image ImageLoader loader = new ImageLoader(); Image image = xyGraph.getImage(); loader.data = new ImageData[]{image.getImageData()}; image.dispose(); // Prompt for file name String path = SingleSourceHelper.getImageSavePath(); if (path == null || path.length() <= 0) return; // Assert *.png at end of file name if (! path.toLowerCase().endsWith(".png")) path = path + ".png"; // Save loader.save(path, SWT.IMAGE_PNG); } }); }
@Override protected IFigure createFigure() { DirectionalShape figure = new DirectionalShape(); contentPane = new DatasetFigure(); figure.add(contentPane); Button button = new Button(StackedchartsImages .getImage(StackedchartsImages.DESC_DELETE)); button.setToolTip(new Label("Remove the dataset from this axis")); button.addActionListener(this); figure.add(button); return figure; }
public ChartsetFigure(ActionListener addChartHandler) { add(new Label(StackedchartsImages.getImage( StackedchartsImages.DESC_CHARTSET))); chartsetHeader = new DirectionalLabel(Activator.FONT_12); chartsetHeader.setText("Chart Set"); chartsetHeader.setTextAlignment(PositionConstants.TOP); add(chartsetHeader); Button button = new Button(StackedchartsImages.getImage( StackedchartsImages.DESC_ADD)); button.setToolTip(new Label("Add new chart")); button.addActionListener(addChartHandler); add(button); }
private static void createDiagram(IFigure root, VarParser parser) { VariableInfo sum = parser.locateVariable("sum", 24); VariableInfo i = parser.locateVariable("i", 24); MockArray array = new MockArray("int", "a", 1,2,3,4); MockArrayIndex i1 = new MockArrayIndex(i.getName(), null, 1, IArrayIndexModel.Direction.FORWARD,-4); // MockArrayIndex v = new MockArrayIndex(v, null, 0, IArrayIndexModel.Direction.FORWARD, 3); ; array.addIndexVariable(i1); ArrayPrimitiveFigure fig = new ArrayPrimitiveFigure(array); fig.setSize(fig.getPreferredSize()); fig.setLocation(new Point(100, 100)); root.add(fig); Button but = new Button("test"); but.setLocation(new Point(5, 5)); but.setSize(but.getPreferredSize()); but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { try { array.set(i1.getCurrentIndex(), 9); i1.set(i1.getCurrentIndex() + 1); i1.set(i1.getCurrentIndex() - 1); } catch(IndexOutOfBoundsException e) { e.printStackTrace(); } } }); root.add(but); }
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; }
@Override protected IFigure createFigure() { DirectionalShape figure = new DirectionalShape(); scatterSetNameLabel = new DirectionalIconLabel(StackedchartsImages.getImage( StackedchartsImages.DESC_DATASET)); figure.add(scatterSetNameLabel); final Button button = new Button(StackedchartsImages.getImage( StackedchartsImages.DESC_DELETE)); button.setToolTip(new Label("Remove scatter set")); button.addActionListener(this); figure.add(button); return figure; }
private static void createDiagram(IFigure root) { // Array com iteradores MockArray array = new MockArray("Integer", 1,2,3,4,5); // MockVariable var = new MockVariable("int[]", "v", null, array); MockReference ref = new MockReference("int[]", "v", array, false); MockValue i1 = new MockValue("int", "i1", null, 0, false); MockArrayIndex ii1 = new MockArrayIndex(i1, ref, Direction.NONE); MockValue i2 = new MockValue("int", "i2", null, 1, false); MockArrayIndex ii2 = new MockArrayIndex(i2, ref, Direction.FORWARD); MockValue i3 = new MockValue("int", "i3", null, 5, false); MockArrayIndex ii3 = new MockArrayIndex(i3, ref, Direction.FORWARD, new MyBound(-1, BoundType.OPEN, "-1")); // array.addIndexVariable(ii1); // array.addIndexVariable(ii2); // array.addIndexVariable(ii3); List<IArrayIndexModel> vars = new ArrayList<>(); vars.add(ii1); vars.add(ii2); ArrayReferenceFigure fig = new ArrayReferenceFigure(array); fig.setLocation(new Point(100, 100)); root.add(fig); // IllustrationBorder b = new IllustrationBorder(vars, fig); // MarginBorder b = new MarginBorder(15); // fig.setBorder(b); // Array com lenght maior que o tamanho maximo da figura MockArray array2 = new MockArray("int", 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25); ArrayPrimitiveFigure fig2 = new ArrayPrimitiveFigure(array2); fig2.setLocation(new Point(250, 300)); root.add(fig2); // Array vazia MockArray array3 = new MockArray("int"); ArrayPrimitiveFigure fig3 = new ArrayPrimitiveFigure(array3); fig3.setLocation(new Point(400, 200)); root.add(fig3); Connection c = new PolylineConnection(); ChopboxAnchor a = new ChopboxAnchor(fig); ChopboxAnchor b = new ChopboxAnchor(fig2); c.setSourceAnchor(a); c.setTargetAnchor(b); root.add(c); Button but = new Button("test"); but.setLocation(new Point(5, 5)); but.setSize(but.getPreferredSize()); but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { i1.set(ii1.getCurrentIndex()+1); try { if(ii3.getBound().getValue() != ii3.getCurrentIndex()) { i3.set(ii3.getCurrentIndex() - 1); } array.set(ii3.getCurrentIndex(), 9); } catch(IndexOutOfBoundsException e) { e.printStackTrace(); } fig.repaint(); } }); root.add(but); }
public AxisNameFigure(ActionListener deleteHandler) { add(new Label(StackedchartsImages.getImage(StackedchartsImages.DESC_AXIS))); nameLabel = new DirectionalLabel(Activator.FONT_10); nameLabel.setTextAlignment(PositionConstants.TOP); add(nameLabel); Button button = new Button(StackedchartsImages.getImage(StackedchartsImages.DESC_DELETE)); button.setToolTip(new Label("Remove this axis from the chart")); button.addActionListener(deleteHandler); add(button); }
/** * The constructor of this class, where the constructor {@link ORMShapeFigure#ORMShapeFigure()} * is called, the basic {@link ShadowRectangle} is initialized, expandable/collapsable * {@link PartFigure} rectangle2 is initialized and added to the basic rectangle, the * {@link Button} for the expandaning/collapsing is initialized and added to rectangle2, the child * figures for the name( {@link Label}) is added to the basic rectangle. * * */ public ORMCompartmentV2Figure() { super(); rectangle = new ShadowRectangle(); rectangle2 = new PartFigure(); image = new Image(null, ImageDescriptor .createFromFile(this.getClass(), "../icons/expandArrow3.png").createImage(), SWT.IMAGE_COPY); expandCollapseButton = new Button(image); expandCollapseButton.setStyle(Button.STYLE_BUTTON); // to only show the image of the button // the border must set to null and opaque to false expandCollapseButton.setBorder(null); expandCollapseButton.setOpaque(false); BorderLayout layout = new BorderLayout(); ToolbarLayout layout2 = new ToolbarLayout(); XYLayout layout3 = new XYLayout(); layout2.setSpacing(4); // set the initial heigth of the child figures layout2.setHorizontal(false); layout.setHorizontalSpacing(-1); layout.setVerticalSpacing(-1); setLayoutManager(layout3); setBackgroundColor(ColorConstants.white); rectangle.setLayoutManager(layout); rectangle2.setLayoutManager(layout2); rectangle.setFill(false); // add name figure rectangle.add(getLabel(), BorderLayout.TOP); // add button rectangle2.add(expandCollapseButton); // add expandable/ collapsable structure rectangle.add(rectangle2, BorderLayout.LEFT); add(rectangle); }
/** * A getter for the button through which the expandable/collapsable structure of this figure can * expanded/collapsed. * * @return expandCollapseButton {@link Button} * */ public Button getButton() { return expandCollapseButton; }