/** * This method allows subclasses to do perform additonal user interactions * after the new figure has been created. * The implementation of this class just invokes fireToolDone. */ @Override protected void creationFinished(Figure createdFigure) { getView().clearSelection(); getView().addToSelection(createdFigure); beginEdit((TextHolderFigure) createdFigure); } /*
@Override public void actionPerformed(ActionEvent event) { endEdit(); if (isToolDoneAfterCreation()) { fireToolDone(); } } }
protected void beginEdit(TextHolderFigure textHolder) { if (textArea == null) { textArea = new FloatingTextArea(); //textArea.addActionListener(this); } if (textHolder != typingTarget && typingTarget != null) { endEdit(); } textArea.createOverlay(getView(), textHolder); textArea.setBounds(getFieldBounds(textHolder), textHolder.getText()); textArea.requestFocus(); typingTarget = textHolder; }
p.add(btn, gbc); textAreaTool = new TextAreaCreationTool(new SVGTextAreaFigure(), attributes); textAreaTool.setRubberbandColor(Color.BLACK); textAreaTool.setToolDoneAfterCreation(true); btn = ButtonFactory.addToolTo(this, editor, textAreaTool, "createTextArea", labels); btn.setUI((PaletteButtonUI) PaletteButtonUI.createUI(btn));
} else { if (createdFigure != null) { getDrawing().remove((Figure) getAddedFigure()); getDrawing().fireUndoableEditHappened(edit);
attributes.put(AttributeKeys.STROKE_COLOR, null); ButtonFactory.addToolTo(tb, editor, new CreationTool(new SVGTextFigure(), attributes), "edit.createText", drawLabels); TextAreaCreationTool tat = new TextAreaCreationTool(new SVGTextAreaFigure(), attributes); tat.setRubberbandColor(Color.BLACK); ButtonFactory.addToolTo(tb, editor, tat, "edit.createTextArea", drawLabels);
private void addCreationButtonsTo(JToolBar tb, final DrawingEditor editor) { // AttributeKeys for the entitie sets HashMap<AttributeKey,Object> attributes; ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.samples.pert.Labels"); ResourceBundleUtil drawLabels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); ButtonFactory.addSelectionToolTo(tb, editor); tb.addSeparator(); attributes = new HashMap<AttributeKey,Object>(); attributes.put(AttributeKeys.FILL_COLOR, Color.white); attributes.put(AttributeKeys.STROKE_COLOR, Color.black); attributes.put(AttributeKeys.TEXT_COLOR, Color.black); ButtonFactory.addToolTo(tb, editor, new CreationTool(new TaskFigure(), attributes), "edit.createTask", labels); attributes = new HashMap<AttributeKey,Object>(); attributes.put(AttributeKeys.STROKE_COLOR, new Color(0x000099)); ButtonFactory.addToolTo(tb, editor, new ConnectionTool(new DependencyFigure(), attributes), "edit.createDependency", labels); tb.addSeparator(); ButtonFactory.addToolTo(tb, editor, new TextAreaCreationTool(new TextAreaFigure()), "edit.createTextArea", drawLabels); }
@Override public void deactivate(DrawingEditor editor) { endEdit(); super.deactivate(editor); }
@Override public void draw(Graphics2D g) { if (createdFigure != null && rubberbandColor != null) { g.setColor(rubberbandColor); g.draw(getView().drawingToView(createdFigure.getBounds())); } }
private void addCreationButtonsTo(JToolBar tb, final DrawingEditor editor) { // AttributeKeys for the entitie sets HashMap<AttributeKey, Object> attributes; ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.samples.pert.Labels"); ResourceBundleUtil drawLabels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); ButtonFactory.addSelectionToolTo(tb, editor); tb.addSeparator(); attributes = new HashMap<AttributeKey, Object>(); attributes.put(AttributeKeys.FILL_COLOR, Color.white); attributes.put(AttributeKeys.STROKE_COLOR, Color.black); attributes.put(AttributeKeys.TEXT_COLOR, Color.black); ButtonFactory.addToolTo(tb, editor, new CreationTool(new TaskFigure(), attributes), "edit.createTask", labels); attributes = new HashMap<AttributeKey, Object>(); attributes.put(AttributeKeys.STROKE_COLOR, new Color(0x000099)); ButtonFactory.addToolTo(tb, editor, new ConnectionTool(new DependencyFigure(), attributes), "edit.createDependency", labels); tb.addSeparator(); ButtonFactory.addToolTo(tb, editor, new TextAreaCreationTool(new TextAreaFigure()), "edit.createTextArea", drawLabels); }
/** * Creates a new figure at the mouse location. * If editing is in progress, this finishes editing. */ @Override public void mousePressed(MouseEvent e) { // Note: The search sequence used here, must be // consistent with the search sequence used by the // HandleTracker, SelectAreaTracker, DelegationSelectionTool, SelectionTool. if (typingTarget != null) { endEdit(); if (isToolDoneAfterCreation()) { fireToolDone(); } } else { super.mousePressed(e); } }
ButtonFactory.addToolTo(tb, editor, new BezierTool(new BezierFigure(true)), "edit.createPolygon", labels); ButtonFactory.addToolTo(tb, editor, new TextCreationTool(new TextFigure()), "edit.createText", labels); ButtonFactory.addToolTo(tb, editor, new TextAreaCreationTool(new TextAreaFigure()), "edit.createTextArea", labels);
ButtonFactory.addToolTo(tb, editor, new BezierTool(new BezierFigure(true)), "edit.createPolygon", labels); ButtonFactory.addToolTo(tb, editor, new TextCreationTool(new TextFigure()), "edit.createText", labels); ButtonFactory.addToolTo(tb, editor, new TextAreaCreationTool(new TextAreaFigure()), "edit.createTextArea", labels); ButtonFactory.addToolTo(tb, editor, new ImageTool(new ImageFigure()), "edit.createImage", labels);