@Override public final Collection<Handle> createSecondaryHandles() { LinkedList<Handle> list = new LinkedList<Handle>(); if (((ConnectionFigure) getOwner()).getLiner() == null && savedLiner == null) { int index = getBezierNodeIndex(); BezierFigure f = getBezierFigure(); BezierPath.Node v = f.getNode(index); if ((v.mask & BezierPath.C1_MASK) != 0 && (index != 0 || f.isClosed())) { list.add(new BezierControlPointHandle(f, index, 1)); } if ((v.mask & BezierPath.C2_MASK) != 0 && (index < f.getNodeCount() - 1 || f.isClosed())) { list.add(new BezierControlPointHandle(f, index, 2)); } if (index > 0 || f.isClosed()) { int i = (index == 0) ? f.getNodeCount() - 1 : index - 1; v = f.getNode(i); if ((v.mask & BezierPath.C2_MASK) != 0) { list.add(new BezierControlPointHandle(f, i, 2)); } } if (index < f.getNodeCount() - 2 || f.isClosed()) { int i = (index == f.getNodeCount() - 1) ? 0 : index + 1; v = f.getNode(i); if ((v.mask & BezierPath.C1_MASK) != 0) { list.add(new BezierControlPointHandle(f, i, 1)); } } } return list; }
/** * Creates toolbars for the application. This class always returns an empty list. Subclasses may * return other values. */ @Override public List<JToolBar> createToolBars(Application a, @Nullable View pr) { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); DrawView p = (DrawView) pr; DrawingEditor editor; if (p == null) { editor = getSharedEditor(); } else { editor = p.getEditor(); } LinkedList<JToolBar> list = new LinkedList<JToolBar>(); JToolBar tb; tb = new JToolBar(); addCreationButtonsTo(tb, editor); tb.setName(labels.getString("window.drawToolBar.title")); list.add(tb); tb = new JToolBar(); ButtonFactory.addAttributesButtonsTo(tb, editor); tb.setName(labels.getString("window.attributesToolBar.title")); list.add(tb); tb = new JToolBar(); ButtonFactory.addAlignmentButtonsTo(tb, editor); tb.setName(labels.getString("window.alignmentToolBar.title")); list.add(tb); return list; }
public java.util.List<Figure> findFigures(Rectangle2D.Double r) { LinkedList<Figure> c = new LinkedList<Figure>(quadTree.findIntersects(r)); switch (c.size()) { case 0: // fall through case 1: return c; default: return sort(c); } }
public java.util.List<Figure> findFiguresWithin(Rectangle2D.Double bounds) { LinkedList<Figure> contained = new LinkedList<Figure>(); for (Figure f : children) { Rectangle2D r = f.getBounds(); if (AttributeKeys.TRANSFORM.get(f) != null) { r = AttributeKeys.TRANSFORM.get(f).createTransformedShape(r).getBounds2D(); } if (f.isVisible() && bounds.contains(r)) { contained.add(f); } } return contained; }
public static Collection<Action> createSelectionActions(DrawingEditor editor) { LinkedList<Action> a = new LinkedList<Action>(); a.add(new DuplicateAction()); a.add(null); // separator a.add(new GroupAction(editor, new SVGGroupFigure())); a.add(new UngroupAction(editor, new SVGGroupFigure())); a.add(new CombineAction(editor)); a.add(new SplitAction(editor)); a.add(null); // separator a.add(new BringToFrontAction(editor)); a.add(new SendToBackAction(editor)); return a; }
@Override public Collection<Action> getActions(Point2D.Double p) { LinkedList<Action> actions = new LinkedList<Action>(); if (get(TRANSFORM) != null) { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.samples.odg.Labels"); actions.add( new AbstractAction(labels.getString("edit.removeTransform.text")) { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent evt) { willChange(); fireUndoableEditHappened(TRANSFORM.setUndoable(ODGAttributedFigure.this, null)); changed(); } }); } return actions; }
@Override public Collection<Handle> createHandles(int detailLevel) { LinkedList<Handle> handles = new LinkedList<Handle>(); switch (detailLevel % 2) { case -1: // Mouse hover handles handles.add(new BezierOutlineHandle(this, true)); break; case 0: handles.add(new BezierOutlineHandle(this)); for (int i = 0, n = path.size(); i < n; i++) { handles.add(new BezierNodeHandle(this, i)); } break; case 1: TransformHandleKit.addTransformHandles(this, handles); handles.add(new BezierScaleHandle(this)); break; } return handles; }
private Drawing createDrawing() { DefaultDrawing drawing = new DefaultDrawing(); LinkedList<InputFormat> inputFormats = new LinkedList<InputFormat>(); inputFormats.add(new SVGInputFormat()); inputFormats.add(new SVGZInputFormat()); inputFormats.add(new ImageInputFormat(new SVGImageFigure())); inputFormats.add(new TextInputFormat(new SVGTextFigure())); LinkedList<OutputFormat> outputFormats = new LinkedList<OutputFormat>(); outputFormats.add(new SVGOutputFormat()); outputFormats.add(new ImageOutputFormat()); drawing.setInputFormats(inputFormats); drawing.setOutputFormats(outputFormats); return drawing; }
public Collection<Handle> createHandles(int detailLevel) { LinkedList<Handle> handles = new LinkedList<Handle>(); switch (detailLevel % 2) { case -1: // Mouse hover handles handles.add(new BoundsOutlineHandle(this, false, true)); break; case 0: handles.add(new BoundsOutlineHandle(this)); handles.add(new MoveHandle(this, RelativeLocator.northWest())); handles.add(new MoveHandle(this, RelativeLocator.northEast())); handles.add(new MoveHandle(this, RelativeLocator.southWest())); handles.add(new MoveHandle(this, RelativeLocator.southEast())); handles.add(new FontSizeHandle(this)); handles.add(new LinkHandle(this)); break; case 1: TransformHandleKit.addTransformHandles(this, handles); break; } return handles; }
@Override public Collection<Handle> createHandles(int detailLevel) { LinkedList<Handle> handles = new LinkedList<Handle>(); switch (detailLevel) { case -1: handles.add(new BoundsOutlineHandle(this, false, true)); break; case 0: handles.add(new BoundsOutlineHandle(this)); handles.add(new MoveHandle(this, RelativeLocator.northWest())); handles.add(new MoveHandle(this, RelativeLocator.northEast())); handles.add(new MoveHandle(this, RelativeLocator.southWest())); handles.add(new MoveHandle(this, RelativeLocator.southEast())); handles.add(new FontSizeHandle(this)); break; } return handles; }