@Override public void figureChanged(FigureEvent e) { if (!owner.isChanging()) { owner.willChange(); owner.fireFigureChanged(e); owner.changed(); } }
/** * Draw the figure. This method is delegated to the encapsulated presentation figure. */ @Override public void draw(Graphics2D g) { drawPresentationFigure(g); super.draw(g); }
@Override public void areaInvalidated(FigureEvent e) { if (!owner.isChanging()) { owner.fireAreaInvalidated(e.getInvalidatedArea()); } }
/** * Sets an attribute of the figure. * AttributeKey name and semantics are defined by the class implementing * the figure interface. */ @Override public <T> void set(AttributeKey<T> key, T newValue) { if (forbiddenAttributes == null || !forbiddenAttributes.contains(key)) { if (getPresentationFigure() != null) { getPresentationFigure().set(key, newValue); } T oldValue = (T) key.put(attributes, newValue); fireAttributeChanged(key, oldValue, newValue); } }
GraphicalCompositeFigure gcf = new GraphicalCompositeFigure(); gcf.setLayouter(new VerticalLayouter()); gcf.set(COMPOSITE_ALIGNMENT, Alignment.CENTER); gcf.add(imf); gcf.add(tef); gcf.layout(); rowHeight = 0; Rectangle2D.Double b = gcf.getBounds(); rowHeight = Math.max(rowHeight, b.height); gcf.transform(at);
@Override public void run() { // Create a graphical composite figure. GraphicalCompositeFigure composite = new GraphicalCompositeFigure(); // Add child figures to the composite figure composite.add(new TextFigure("Above the line")); composite.add(new LineFigure()); composite.add(new TextFigure("Below the line")); // Set a layouter and perform the layout composite.setLayouter(new VerticalLayouter()); composite.layout(); // Add the composite figure to a drawing Drawing drawing = new DefaultDrawing(); drawing.add(composite); // Create a frame with a drawing view and a drawing editor JFrame f = new JFrame("My Drawing"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(400, 300); DrawingView view = new DefaultDrawingView(); view.setDrawing(drawing); f.getContentPane().add(view.getComponent()); DrawingEditor editor = new DefaultDrawingEditor(); editor.add(view); editor.setTool(new DelegationSelectionTool()); f.setVisible(true); } });
/** * Moves the figure. This is the * method that subclassers override. Clients usually * call displayBox. */ @Override public void setBounds(Point2D.Double anchor, Point2D.Double lead) { if (getLayouter() == null) { super.setBounds(anchor, lead); basicSetPresentationFigureBounds(anchor, lead); } else { Rectangle2D.Double r = getLayouter().layout(this, anchor, lead); basicSetPresentationFigureBounds(new Point2D.Double(r.getX(), r.getY()), new Point2D.Double( Math.max(lead.x, (int) r.getMaxX()), Math.max(lead.y, (int) r.getMaxY()))); invalidate(); } }
@Override public void undoableEditHappened(UndoableEditEvent e) { owner.fireUndoableEditHappened(e.getEdit()); } };
@Override public TaskFigure clone() { TaskFigure that = (TaskFigure) super.clone(); that.dependencies = new HashSet<DependencyFigure>(); that.getNameFigure().addFigureListener(new NameAdapter(that)); that.getDurationFigure().addFigureListener(new DurationAdapter(that)); that.updateStartTime(); return that; }