Line | Hits | Source |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2005, the JUNG Project and the Regents of the University | |
3 | * of California | |
4 | * All rights reserved. | |
5 | * | |
6 | * This software is open-source under the BSD license; see either | |
7 | * "license.txt" or | |
8 | * http://jung.sourceforge.net/license.txt for a description. | |
9 | * Created on Mar 8, 2005 | |
10 | * | |
11 | */ | |
12 | package edu.uci.ics.jung.visualization.control; | |
13 | ||
14 | import java.awt.ItemSelectable; | |
15 | import java.awt.event.InputEvent; | |
16 | ||
17 | ||
18 | /** | |
19 | * | |
20 | * DefaultModalGraphMouse is a PluggableGraphMouse class that | |
21 | * pre-installs a large collection of plugins for picking and | |
22 | * transforming the graph. Additionally, it carries the notion | |
23 | * of a Mode: Picking or Translating. Switching between modes | |
24 | * allows for a more natural choice of mouse modifiers to | |
25 | * be used for the various plugins. The default modifiers are | |
26 | * intended to mimick those of mainstream software applications | |
27 | * in order to be intuitive to users. | |
28 | * | |
29 | * To change between modes, two different controls are offered, | |
30 | * a combo box and a menu system. These controls are lazily created | |
31 | * in their respective 'getter' methods so they don't impact | |
32 | * code that does not intend to use them. | |
33 | * The menu control can be placed in an unused corner of the | |
34 | * GraphZoomScrollPane, which is a common location for mouse | |
35 | * mode selection menus in mainstream applications. | |
36 | * | |
37 | * @author Tom Nelson | |
38 | */ | |
39 | public class DefaultModalGraphMouse extends AbstractModalGraphMouse | |
40 | implements ModalGraphMouse, ItemSelectable { | |
41 | ||
42 | /** | |
43 | * create an instance with default values | |
44 | * | |
45 | */ | |
46 | public DefaultModalGraphMouse() { | |
47 | 0 | this(1.1f, 1/1.1f); |
48 | 0 | } |
49 | ||
50 | /** | |
51 | * create an instance with passed values | |
52 | * @param in override value for scale in | |
53 | * @param out override value for scale out | |
54 | */ | |
55 | 0 | public DefaultModalGraphMouse(float in, float out) { |
56 | 0 | this.in = in; |
57 | 0 | this.out = out; |
58 | 0 | loadPlugins(); |
59 | 0 | } |
60 | ||
61 | /** | |
62 | * create the plugins, and load the plugins for TRANSFORMING mode | |
63 | * | |
64 | */ | |
65 | protected void loadPlugins() { | |
66 | 0 | pickingPlugin = new PickingGraphMousePlugin(); |
67 | 0 | animatedPickingPlugin = new AnimatedPickingGraphMousePlugin(); |
68 | 0 | translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK); |
69 | 0 | scalingPlugin = new ScalingGraphMousePlugin(new CrossoverScalingControl(), 0, in, out); |
70 | 0 | rotatingPlugin = new RotatingGraphMousePlugin(); |
71 | 0 | shearingPlugin = new ShearingGraphMousePlugin(); |
72 | ||
73 | 0 | add(scalingPlugin); |
74 | 0 | setMode(Mode.TRANSFORMING); |
75 | 0 | } |
76 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |