Codota Logo
DrawingEditor
Code IndexAdd Codota to your IDE (free)

How to use
DrawingEditor
in
org.jhotdraw.draw

Best Java code snippets using org.jhotdraw.draw.DrawingEditor (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Gson g =
  • Codota Iconnew Gson()
  • Codota IconGsonBuilder gsonBuilder;gsonBuilder.create()
  • Codota Iconnew GsonBuilder().create()
  • Smart code suggestions by Codota
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void add(DrawingView view) {
  target.add(view);
}

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void setTool(Tool t) {
  target.setTool(t);
}

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public SelectionComponentDisplayer(DrawingEditor editor, JComponent component) {
  this.editor = editor;
  this.weakRef = new WeakReference<JComponent>(component);
  if (editor.getActiveView() != null) {
    view = editor.getActiveView();
    view.addPropertyChangeListener(this);
    view.addFigureSelectionListener(this);
  }
  editor.addPropertyChangeListener(this);
  updateVisibility();
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Sets a drawing editor for the view.
 */
public void setEditor(DrawingEditor newValue) {
  if (editor != null) {
    editor.remove(view);
  }
  editor = newValue;
  if (editor != null) {
    editor.add(view);
  }
}

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

protected void drawTool(Graphics2D g) {
  if (editor != null && editor.getActiveView() == this && editor.getTool() != null) {
    editor.getTool().draw(g);
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Sets the target of the proxy.
 */
public void setTarget(@Nullable DrawingEditor newValue) {
  if (target != null) {
    target.removePropertyChangeListener(forwarder);
  }
  this.target = newValue;
  if (target != null) {
    target.addPropertyChangeListener(forwarder);
  }
}
/**
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

editor.add(view);
editor.setTool(new SelectionTool());
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

f.getContentPane().add(view.getComponent());
DrawingEditor editor = new DefaultDrawingEditor();
editor.setTool(new DelegationSelectionTool());
editor.add(view);
editor.setActiveView(view);
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public void setEditor(@Nullable DrawingEditor newValue) {
  DrawingEditor oldValue = editor;
  if (oldValue != null) {
    oldValue.remove(view);
  }
  editor = newValue;
  if (newValue != null) {
    newValue.add(view);
  }
  creationToolBar.setEditor(editor);
  fillToolBar.setEditor(editor);
  strokeToolBar.setEditor(editor);
  actionToolBar.setUndoManager(undoManager);
  actionToolBar.setEditor(editor);
  alignToolBar.setEditor(editor);
  arrangeToolBar.setEditor(editor);
  fontToolBar.setEditor(editor);
  figureToolBar.setEditor(editor);
  linkToolBar.setEditor(editor);
  DrawingView temp = (editor == null) ? null : editor.getActiveView();
  if (editor != null) {
    editor.setActiveView(view);
  }
  canvasToolBar.setEditor(editor);
  viewToolBar.setEditor(editor);
  if (editor != null) {
    editor.setActiveView(temp);
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

if (!evt.isConsumed()) {
  if (evt.getSource() instanceof Container) {
    editor.setActiveView(editor.findView((Container) evt.getSource()));
    InputMap im = editor.getInputMap();
    if (im != null) {
      obj = im.get(KeyStroke.getKeyStroke(evt.getKeyCode(), evt.getModifiers(), false));
      al = editor.getActionMap().get(obj);
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public DrawingView getActiveView() {
  return (target == null) ? null : target.getActiveView();
}

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

  @Override
  public void paintIcon(java.awt.Component c, java.awt.Graphics gr, int x, int y) {
    Graphics2D g = (Graphics2D) gr;
    super.paintIcon(c, g, x, y);
    Color color;
    DrawingView view = editor.getActiveView();
    if (view != null && view.getSelectedFigures().size() == 1) {
      color = view.getSelectedFigures().iterator().next().get(key);
    } else {
      color = key.get(editor.getDefaultAttributes());
    }
    if (color != null) {
      g.setColor(color);
      g.translate(x, y);
      g.fill(colorShape);
      g.translate(-x, -y);
    }
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public DrawingView findView(Container c) {
  return target.findView(c);
}

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void show(Component invoker, int x, int y) {
  if (colorChooser == null) {
    initialize();
  }
  Color c;
  if (editor.getActiveView() != null && editor.getActiveView().getSelectionCount() > 0) {
    c = editor.getActiveView().getSelectedFigures().iterator().next().get(attributeKey);
  } else {
    c = editor.getDefaultAttribute(attributeKey);
  }
  colorChooser.setColor(c == null ? new Color(0, true) : c);
  super.show(invoker, x, y);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

  @Override
  public void dispose() {
    if (editor != null) {
      if (editor.getActiveView() != null) {
        DrawingView view = editor.getActiveView();
        view.removePropertyChangeListener(this);
        if (view.getDrawing() != null) {
          view.getDrawing().removeFigureListener(this);
        }
      }
      editor.removePropertyChangeListener(this);
      editor = null;
    }
    component = null;
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void mouseMoved(MouseEvent evt) {
  Point point = evt.getPoint();
  updateCursor(editor.findView((Container) evt.getSource()), point);
  DrawingView view = editor.findView((Container) evt.getSource());
  updateCursor(view, point);
  if (view == null || editor.getActiveView() != view) {
    clearHoverHandles();
  } else {
    // Search first, if one of the selected figures contains
    // the current mouse location. Only then search for other
    // figures. This search sequence is consistent with the
    // search sequence of the SelectionTool.
    Figure figure = null;
    Point2D.Double p = view.viewToDrawing(point);
    for (Figure f : view.getSelectedFigures()) {
      if (f.contains(p)) {
        figure = f;
      }
    }
    if (figure == null) {
      figure = view.findFigure(point);
      Drawing drawing = view.getDrawing();
      while (figure != null && !figure.isSelectable()) {
        figure = drawing.findFigureBehind(p, figure);
      }
    }
    updateHoverHandles(view, figure);
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void applyDefaultAttributesTo(Figure f) {
  target.applyDefaultAttributesTo(f);
}

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public <T> T getDefaultAttribute(AttributeKey<T> key) {
  return target.getDefaultAttribute(key);
}

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

if (editor.getDrawingViews().size() == 0) {
  zoomPopupButton.setText("100 %");
} else {
  zoomPopupButton.setText((int) (editor.getDrawingViews().iterator().next().getScaleFactor() * 100) + " %");
editor.addPropertyChangeListener(new PropertyChangeListener() {
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

  /** Registers the event handler from the drawing editor and the
   * active drawing view.
   */
  private void registerEventHandler() {
    if (editor != null) {
      editor.addPropertyChangeListener(new WeakPropertyChangeListener(eventHandler));
    }
  }
}
org.jhotdraw.drawDrawingEditor

Javadoc

A drawing editor coordinates drawing tools and drawing views.

Usage of drawing editor in conjunction with the JHotDraw application framework:

  • For org.jhotdraw.app.Applications which provide a single document interface (SDI) there is typically one drawing editor instance per org.jhotdraw.app.View. So that each view can have its own toolbars and drawing palettes.
  • For applications with a Windows-style multiple document interface (MDI) there is typically one drawing editor instance per parent window. All views within a parent window share the toolbars and drawing palettes provided be the parent window.
  • For applications with a Mac OS X-style application document interface (OSX) there is typically a single drawing editor instance for the application. All views within the application share a single set of toolbars and drawing palettes.

Design Patterns

Framework
The following interfaces define the contracts of a framework for structured drawing editors:
Contract: Drawing, Figure, DrawingView, DrawingEditor, org.jhotdraw.draw.handle.Handle and org.jhotdraw.draw.tool.Tool.

Mediator
DrawingEditor acts as a mediator for coordinating drawing tools and drawing views:
Mediator: DrawingEditor; Colleagues: DrawingView, org.jhotdraw.draw.tool.Tool.

Mediator
DrawingEditor acts as a mediator for coordinating keyboard input from Tools and Swing action objects:
Mediator: DrawingEditor; Colleagues: org.jhotdraw.draw.tool.Tool, javax.swing.Action.

Model-View-Controller
The following classes implement together the Model-View-Controller design pattern:
Model: Drawing; View: DrawingView; Controller: DrawingEditor.

Observer
State changes of tools can be observed by other objects. Specifically DrawingEditor observes area invalidations of tools and repaints its active drawing view accordingly.
Subject: Tool; Observer: org.jhotdraw.draw.event.ToolListener; Event: org.jhotdraw.draw.event.ToolEvent; Concrete Observer: DrawingEditor.

Proxy
To remove the need for null-handling, AbstractTool makes use of a proxy for DrawingEditor.
Subject: DrawingEditor; Proxy: DrawingEditorProxy; Client: org.jhotdraw.draw.tool.AbstractTool.


Most used methods

  • add
    Adds a drawing view to the editor. The editor invokes addNotify on the view, and it registers its to
  • setTool
    Calls deactivate on the previously active tool of this drawing editor. Calls activate on the provide
  • addPropertyChangeListener
    Adds a PropertyChangeListener.
  • applyDefaultAttributesTo
    Applies the default attributes to the specified figure.
  • findView
    Finds a drawing view. This is used by Tool to identify the view of which it has received an event.
  • getActionMap
    Gets the action map used by the tool of this drawing editor as a fall back for performing actions. T
  • getActiveView
    Gets the editor's active drawing view. This can be null, if the editor has no views.
  • getDefaultAttribute
    Gets a default attribute from the editor. The default attribute will be used by creation tools, to c
  • getDefaultAttributes
    Returns an immutable Map with the default attributes of this editor.
  • getDrawingViews
    Gets all drawing views associated with this editor.
  • getHandleAttribute
    Gets a handle attribute from the editor. The default attribute will be used by creation tools, to cr
  • getInputMap
    Sets the input map used by the tool of this drawing editor as a fall back for handling keyboard even
  • getHandleAttribute,
  • getInputMap,
  • getTool,
  • isEnabled,
  • remove,
  • removePropertyChangeListener,
  • setActionMap,
  • setActiveView,
  • setCursor,
  • setDefaultAttribute

Popular in Java

  • Finding current android device location
  • getExternalFilesDir (Context)
  • setContentView (Activity)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Runner (org.openjdk.jmh.runner)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now