diff --git a/src/main/java/plugins/adufour/protocols/Protocols.java b/src/main/java/plugins/adufour/protocols/Protocols.java index 7d9cd6a886e37bf593120dc6a646c264488bce80..202cd32d5e7f2c75fca4cbdff29455aa5c4161b5 100644 --- a/src/main/java/plugins/adufour/protocols/Protocols.java +++ b/src/main/java/plugins/adufour/protocols/Protocols.java @@ -64,7 +64,7 @@ public class Protocols extends PluginActionable return preferences.get(PREF_FOLDER, System.getProperty("user.home")); } - public static void setDefaultProtocolFolder(String path) + public static void setDefaultProtocolFolder(final String path) { preferences.put(PREF_FOLDER, path); } @@ -87,22 +87,21 @@ public class Protocols extends PluginActionable return reloading; } - public static void setReloading(boolean value) + public static void setReloading(final boolean value) { reloading = value; } /** - * Saves the current state of the Protocols interface and restarts it.<br/> - * This method is useful when plug-ins have been modified (via the plug-in loader) and requires - * Protocols to restart to take into account the new changes - * - * @param reloadingNode - * the node that caused the reload operation (should be reloaded last) - * @throws TransformerFactoryConfigurationError - * @throws TransformerException - */ - public void reload(Document reloadingXML, String reloadingPath) + * Saves the current state of the Protocols interface and restarts it. + * <p> + * This method is useful when plug-ins have been modified (via the plug-in + * loader) and requires Protocols to restart to take into account the new + * changes + * + * @throws TransformerFactoryConfigurationError + */ + public void reload(final Document reloadingXML, final String reloadingPath) { // 0) avoid silly situations... if (mainFrame == null) @@ -118,11 +117,11 @@ public class Protocols extends PluginActionable int counter = 1; // save protocols to the preferences file one by one - for (ProtocolPanel protocol : mainFrame.getProtocolPanels()) + for (final ProtocolPanel protocol : mainFrame.getProtocolPanels()) { try { - File attachedFile = protocol.getFile(); + final File attachedFile = protocol.getFile(); String xmlProtocol; if (attachedFile != null && attachedFile.getAbsolutePath().equals(reloadingPath)) @@ -134,13 +133,13 @@ public class Protocols extends PluginActionable xmlProtocol = BlocksML.getInstance().toString(protocol.getWorkFlow()); } - XMLPreferences node = preferences.node("Protocol #" + counter++); + final XMLPreferences node = preferences.node("Protocol #" + counter++); node.putBoolean("dirty", protocol.isDirty()); node.put("xml", xmlProtocol); if (attachedFile != null) node.put("fileName", attachedFile.getAbsolutePath()); } - catch (TransformerException e) + catch (final TransformerException e) { System.err.println("Warning: couldn't store protocol " + protocol.getName() + ":"); e.printStackTrace(); @@ -154,14 +153,15 @@ public class Protocols extends PluginActionable ThreadUtil.invokeLater(new Runnable() { - public void run() + @Override + public void run() { // 3) launch a new instance of the Protocols plug-in try { ((PluginActionable) PluginLoader.getPluginClass(Protocols.class.getName()).newInstance()).run(); } - catch (Exception e) + catch (final Exception e) { e.printStackTrace(); } @@ -197,17 +197,17 @@ public class Protocols extends PluginActionable try { - int x = preferences.getInt("Window X", mainFrame.getX()); - int y = preferences.getInt("Window Y", mainFrame.getY()); + final int x = preferences.getInt("Window X", mainFrame.getX()); + final int y = preferences.getInt("Window Y", mainFrame.getY()); mainFrame.setLocation(x, y); - String protocolPath = parseCommandLineArgs(false); + final String protocolPath = parseCommandLineArgs(false); // we have a protocol filename specified ? if (protocolPath != null) { - ProtocolPanel panel = new ProtocolPanel(mainFrame); - Document xml = XMLUtil.loadDocument(protocolPath); + final ProtocolPanel panel = new ProtocolPanel(mainFrame); + final Document xml = XMLUtil.loadDocument(protocolPath); // Discard invalid files if (xml != null) @@ -221,7 +221,7 @@ public class Protocols extends PluginActionable { panel.loadWorkFlow(xml, true); } - catch (BlocksReloadedException e) + catch (final BlocksReloadedException e) { reload(xml, panel.getFile().getAbsolutePath()); return; @@ -231,24 +231,24 @@ public class Protocols extends PluginActionable else { // Reload potential temporary protocols from the preferences - ArrayList<XMLPreferences> protocols = preferences.getChildren(); + final ArrayList<XMLPreferences> protocols = preferences.getChildren(); // no protocol info in XML preference if (protocols.size() == 0) mainFrame.addProtocolPane(new ProtocolPanel(mainFrame)); else { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - for (XMLPreferences node : preferences.getChildren()) + for (final XMLPreferences node : preferences.getChildren()) { - ProtocolPanel panel = new ProtocolPanel(mainFrame); - String fileName = node.get("fileName", null); + final ProtocolPanel panel = new ProtocolPanel(mainFrame); + final String fileName = node.get("fileName", null); if (fileName != null) panel.setFile(new File(fileName)); mainFrame.addProtocolPane(panel); - Document xml = builder.parse(new InputSource(new StringReader(node.get("xml", null)))); + final Document xml = builder.parse(new InputSource(new StringReader(node.get("xml", null)))); try { @@ -257,7 +257,7 @@ public class Protocols extends PluginActionable // if the protocol loads correctly, remove it from the preferences preferences.remove(node.name()); } - catch (BlocksReloadedException e) + catch (final BlocksReloadedException e) { reload(xml, panel.getFile().getAbsolutePath()); return; @@ -266,15 +266,15 @@ public class Protocols extends PluginActionable } } } - catch (ParserConfigurationException e) + catch (final ParserConfigurationException e) { e.printStackTrace(); } - catch (SAXException e) + catch (final SAXException e) { e.printStackTrace(); } - catch (IOException e) + catch (final IOException e) { e.printStackTrace(); } @@ -286,13 +286,13 @@ public class Protocols extends PluginActionable /** * Build the command line arguments map and return protocol path if any is specified */ - private static String parseCommandLineArgs(boolean verify) + private static String parseCommandLineArgs(final boolean verify) { - String[] clargs = Icy.getCommandLinePluginArgs(); + final String[] clargs = Icy.getCommandLinePluginArgs(); String result = null; boolean ok = false; - for (String clarg : clargs) + for (final String clarg : clargs) { // Sanity check if (!clarg.contains("=")) @@ -304,7 +304,7 @@ public class Protocols extends PluginActionable continue; } - String[] keyValuePair = clarg.split("="); + final String[] keyValuePair = clarg.split("="); if (keyValuePair.length != 2) { if (verify) @@ -314,8 +314,8 @@ public class Protocols extends PluginActionable continue; } - String key = keyValuePair[0]; - String value = keyValuePair[1]; + final String key = keyValuePair[0]; + final String value = keyValuePair[1]; if (key.isEmpty()) { @@ -353,22 +353,22 @@ public class Protocols extends PluginActionable private static void runHeadless() { - String protocolFile = parseCommandLineArgs(true); + final String protocolFile = parseCommandLineArgs(true); - Document xml = XMLUtil.loadDocument(protocolFile); + final Document xml = XMLUtil.loadDocument(protocolFile); // Discard invalid files if (xml == null) throw new IllegalArgumentException(protocolFile + " is not a valid protocol file"); System.out.println("Loading workflow..."); - WorkFlow workFlow = new WorkFlow(true); + final WorkFlow workFlow = new WorkFlow(true); BlocksML.getInstance().loadWorkFlow(xml, workFlow); workFlow.run(); } - public static void loadWorkFlow(File file) + public static void loadWorkFlow(final File file) { if (mainFrame == null) new Protocols().run(); @@ -383,7 +383,7 @@ public class Protocols extends PluginActionable mainFrame = null; } - public static void dispatchEvent(KeyEvent key) + public static void dispatchEvent(final KeyEvent key) { if (mainFrame != null) mainFrame.getContentPane().dispatchEvent(key); diff --git a/src/main/java/plugins/adufour/protocols/gui/ProtocolPanel.java b/src/main/java/plugins/adufour/protocols/gui/ProtocolPanel.java index 5df0e476d1f4206cfecfa4dcd9ed7d67db71e432..57167c0f736f50f4fa9d8eb23a596e71e7d2353f 100644 --- a/src/main/java/plugins/adufour/protocols/gui/ProtocolPanel.java +++ b/src/main/java/plugins/adufour/protocols/gui/ProtocolPanel.java @@ -1,15 +1,5 @@ package plugins.adufour.protocols.gui; -import icy.file.FileUtil; -import icy.file.Saver; -import icy.gui.component.button.IcyButton; -import icy.image.IcyBufferedImage; -import icy.image.IcyBufferedImageUtil; -import icy.resource.ResourceUtil; -import icy.resource.icon.IcyIcon; -import icy.system.IcyHandledException; -import icy.system.thread.ThreadUtil; - import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; @@ -37,6 +27,17 @@ import javax.swing.JTextArea; import org.w3c.dom.Document; +import com.ochafik.io.JTextAreaOutputStream; + +import icy.file.FileUtil; +import icy.file.Saver; +import icy.gui.component.button.IcyButton; +import icy.image.IcyBufferedImage; +import icy.image.IcyBufferedImageUtil; +import icy.resource.ResourceUtil; +import icy.resource.icon.IcyIcon; +import icy.system.IcyHandledException; +import icy.system.thread.ThreadUtil; import plugins.adufour.blocks.lang.BlockDescriptor; import plugins.adufour.blocks.lang.BlockDescriptor.BlockStatus; import plugins.adufour.blocks.lang.Link; @@ -53,8 +54,6 @@ import plugins.adufour.vars.lang.Var; import plugins.adufour.vars.lang.VarString; import plugins.adufour.vars.util.VarListener; -import com.ochafik.io.JTextAreaOutputStream; - @SuppressWarnings("serial") public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyChangeListener { @@ -78,22 +77,22 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC private File xmlFile; - public ProtocolPanel(MainFrame frame) + public ProtocolPanel(final MainFrame frame) { this(null, new WorkFlow(true), frame); } - private ProtocolPanel(File file, final WorkFlow workFlow, MainFrame frame) + private ProtocolPanel(final File file, final WorkFlow workFlow, final MainFrame frame) { // Prepare the log panel - JTextArea logArea = new JTextArea(); + final JTextArea logArea = new JTextArea(); logArea.setOpaque(false); logStream = new JTextAreaOutputStream(logArea); logPanel = new JPanel(new BorderLayout()); logPanel.setOpaque(false); logPanel.add(new JLabel("Execution log", JLabel.CENTER), BorderLayout.NORTH); - JScrollPane logScrollPane = new JScrollPane(logArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + final JScrollPane logScrollPane = new JScrollPane(logArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); logPanel.add(logScrollPane, BorderLayout.CENTER); this.xmlFile = file; @@ -121,11 +120,12 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC statusListener = new VarListener<String>() { @Override - public void valueChanged(Var<String> source, String oldValue, final String newValue) + public void valueChanged(final Var<String> source, final String oldValue, final String newValue) { ThreadUtil.invokeLater(new Runnable() { - public void run() + @Override + public void run() { workFlowStatusLabel.setText(newValue); } @@ -133,7 +133,7 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC } @Override - public void referenceChanged(Var<String> source, Var<? extends String> oldReference, Var<? extends String> newReference) + public void referenceChanged(final Var<String> source, final Var<? extends String> oldReference, final Var<? extends String> newReference) { } @@ -144,7 +144,8 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC ThreadUtil.invokeLater(new Runnable() { - public void run() + @Override + public void run() { splitPane.setDividerLocation(1.0); } @@ -152,43 +153,43 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC } @Override - public void blockAdded(WorkFlow source, BlockDescriptor addedBlock) + public void blockAdded(final WorkFlow source, final BlockDescriptor addedBlock) { setDirty(true); } @Override - public void blockCollapsed(WorkFlow source, BlockDescriptor block, boolean collapsed) + public void blockCollapsed(final WorkFlow source, final BlockDescriptor block, final boolean collapsed) { setDirty(true); } @Override - public void blockDimensionChanged(WorkFlow source, BlockDescriptor block, int newWidth, int newHeight) + public void blockDimensionChanged(final WorkFlow source, final BlockDescriptor block, final int newWidth, final int newHeight) { setDirty(true); } @Override - public void blockLocationChanged(WorkFlow source, BlockDescriptor block, int newX, int newY) + public void blockLocationChanged(final WorkFlow source, final BlockDescriptor block, final int newX, final int newY) { setDirty(true); } @Override - public void blockStatusChanged(WorkFlow source, BlockDescriptor block, BlockStatus status) + public void blockStatusChanged(final WorkFlow source, final BlockDescriptor block, final BlockStatus status) { } @Override - public void blockVariableAdded(WorkFlow source, BlockDescriptor block, Var<?> variable) + public void blockVariableAdded(final WorkFlow source, final BlockDescriptor block, final Var<?> variable) { setDirty(true); } @Override - public <T> void blockVariableChanged(WorkFlow source, BlockDescriptor block, Var<T> variable, T newValue) + public <T> void blockVariableChanged(final WorkFlow source, final BlockDescriptor block, final Var<T> variable, final T newValue) { // Mark the protocol as changed if a user input has changed if (block.inputVars.contains(variable) && variable.getReference() == null) @@ -198,19 +199,19 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC } @Override - public void blockRemoved(WorkFlow source, BlockDescriptor removedBlock) + public void blockRemoved(final WorkFlow source, final BlockDescriptor removedBlock) { setDirty(true); } @Override - public void linkAdded(WorkFlow source, Link<?> addedLink) + public void linkAdded(final WorkFlow source, final Link<?> addedLink) { setDirty(true); } @Override - public void linkRemoved(WorkFlow source, Link<?> removedLink) + public void linkRemoved(final WorkFlow source, final Link<?> removedLink) { setDirty(true); } @@ -235,12 +236,12 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC return workFlow.size() == 0; } - public void setFile(File file) + public void setFile(final File file) { this.xmlFile = file; } - void setDirty(boolean dirty) + void setDirty(final boolean dirty) { firePropertyChange(WORKFLOW_MODIFIED, this.xmlDirty, dirty); this.xmlDirty = dirty; @@ -250,8 +251,6 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC * Saves the protocol to a XML file on disk. If no file was currently known for this protocol, a * dialog appears to ask for one * - * @param askForNewFile - * set to true if the protocol should be saved to a new file (i.e. "save as") * @return true if the saving operation was successful, false if canceled * @throws BlocksException * if an error occurred while saving to disk @@ -260,7 +259,7 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC { if (xmlFile == null) { - JFileChooser jfc = new JFileChooser(Protocols.getDefaultProtocolFolder()); + final JFileChooser jfc = new JFileChooser(Protocols.getDefaultProtocolFolder()); jfc.setFileFilter(BlocksML.XML_FILE_FILTER); jfc.setDialogTitle("Save an Icy protocol..."); @@ -274,7 +273,7 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC Protocols.setDefaultProtocolFolder(file.getParent()); // add extension if omitted - String name = file.getPath(); + final String name = file.getPath(); if (!name.toLowerCase().endsWith(".xml") && !name.toLowerCase().endsWith(".protocol")) { @@ -283,14 +282,14 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC if (file.exists()) { - int option = JOptionPane.showConfirmDialog(this, file.getPath() + " already exists. Overwrite ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION); + final int option = JOptionPane.showConfirmDialog(this, file.getPath() + " already exists. Overwrite ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION); if (option != JOptionPane.OK_OPTION) return false; } xmlFile = file; } - boolean success = saveToDisk(xmlFile); + final boolean success = saveToDisk(xmlFile); if (success) { @@ -309,7 +308,7 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC * @throws BlocksException * if an error occurred while saving to disk */ - public boolean saveToDisk(File f) throws BlocksException + public boolean saveToDisk(final File f) throws BlocksException { if (f == null) return false; @@ -317,18 +316,18 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC { BlocksML.getInstance().saveWorkFlow(workFlow, f); } - catch (IOException e) + catch (final IOException e) { throw new IcyHandledException(e.getMessage()); } - File snapshotFile = new File(FileUtil.setExtension(f.getPath(), "_screenshot.png")); + final File snapshotFile = new File(FileUtil.setExtension(f.getPath(), "_screenshot.png")); try { Saver.saveImage(snapshot(), snapshotFile, true); } - catch (Exception e) + catch (final Exception e) { throw new RuntimeException("Unable to save the snapshot. Reason: " + e.getLocalizedMessage()); } @@ -341,27 +340,27 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC */ public IcyBufferedImage snapshot() { - BufferedImage image = new BufferedImage(workFlowContainer.getWidth(), workFlowContainer.getHeight(), BufferedImage.TYPE_INT_ARGB); + final BufferedImage image = new BufferedImage(workFlowContainer.getWidth(), workFlowContainer.getHeight(), BufferedImage.TYPE_INT_ARGB); - Graphics2D g2d = image.createGraphics(); + final Graphics2D g2d = image.createGraphics(); workFlowContainer.paint(g2d); - Rectangle bounds = workFlowContainer.getContentsBoundingBox(); + final Rectangle bounds = workFlowContainer.getContentsBoundingBox(); - IcyBufferedImage icyImage = IcyBufferedImage.createFrom(image); + final IcyBufferedImage icyImage = IcyBufferedImage.createFrom(image); return IcyBufferedImageUtil.getSubImage(icyImage, bounds.x, bounds.y, bounds.width, bounds.height); } @Override - public void statusChanged(WorkFlow source, String message) + public void statusChanged(final WorkFlow source, final String message) { statusMessage.setValue(message); } @Override - public void workFlowReordered(WorkFlow source) + public void workFlowReordered(final WorkFlow source) { setDirty(true); } @@ -372,7 +371,7 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC } @Override - public void propertyChange(PropertyChangeEvent evt) + public void propertyChange(final PropertyChangeEvent evt) { if (evt.getPropertyName() == WORKFLOW_REPLACED) { @@ -380,7 +379,7 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC } } - private void setWorkFlow(WorkFlow workFlow) + private void setWorkFlow(final WorkFlow workFlow) { if (this.workFlow != null) { @@ -403,20 +402,20 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC removeAll(); } - public void showBlocksPopupMenu(Component invoker) + public void showBlocksPopupMenu(final Component invoker) { - JPopupMenu blocksPopupMenu = new JPopupMenu(); + final JPopupMenu blocksPopupMenu = new JPopupMenu(); new BlocksFinder().createJMenu(blocksPopupMenu, workFlowContainer, new Point()); blocksPopupMenu.show(invoker, 0, invoker.getHeight()); } - public void showBlocksEmbedMenu(Component invoker) + public void showBlocksEmbedMenu(final Component invoker) { - JPopupMenu embedPopupMenu = new JPopupMenu(); + final JPopupMenu embedPopupMenu = new JPopupMenu(); // new BlocksFinder().createEmbedJMenu(embedPopupMenu, container); - Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); - Container c = (Container) focusOwner; + final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + final Container c = (Container) focusOwner; WorkFlowContainer wfc; if (!(c instanceof JLayeredPane)) { @@ -430,7 +429,7 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC embedPopupMenu.show(invoker, 0, invoker.getHeight()); } - public void updateRunButton(IcyButton buttonRun) + public void updateRunButton(final IcyButton buttonRun) { switch (workFlow.getBlockDescriptor().getStatus()) { @@ -449,13 +448,14 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC * @param isDirty * @throws BlocksException */ - public void loadWorkFlow(Document xml, final boolean isDirty) throws BlocksException, BlocksReloadedException + public void loadWorkFlow(final Document xml, final boolean isDirty) throws BlocksException, BlocksReloadedException { BlocksML.getInstance().loadWorkFlow(xml, workFlow); ThreadUtil.invokeLater(new Runnable() { - public void run() + @Override + public void run() { repaint(); setDirty(isDirty); @@ -463,12 +463,12 @@ public class ProtocolPanel extends JPanel implements WorkFlowListener, PropertyC }, true); } - public void addBlockListener(BlockListener blockListener) + public void addBlockListener(final BlockListener blockListener) { workFlow.getBlockDescriptor().addBlockListener(blockListener); } - public void removeBlockListener(BlockListener blockListener) + public void removeBlockListener(final BlockListener blockListener) { workFlow.getBlockDescriptor().removeBlockListener(blockListener); } diff --git a/src/main/java/plugins/adufour/protocols/gui/block/WorkFlowPanel.java b/src/main/java/plugins/adufour/protocols/gui/block/WorkFlowPanel.java index 1ee20018c9a04e359228556e624f47f00b06db4d..6e893656b7b368216d565344658de4538d3bc084 100644 --- a/src/main/java/plugins/adufour/protocols/gui/block/WorkFlowPanel.java +++ b/src/main/java/plugins/adufour/protocols/gui/block/WorkFlowPanel.java @@ -53,7 +53,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener protected final JMenuItem menuRemoveEnclosure = new JMenuItem("Remove block but keep contents"); - public WorkFlowPanel(WorkFlowContainer wfPane, final BlockDescriptor blockDesc) + public WorkFlowPanel(final WorkFlowContainer wfPane, final BlockDescriptor blockDesc) { super(wfPane, blockDesc); @@ -62,13 +62,13 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener mouseAdapter = new MouseAdapter() { @Override - public void mouseClicked(MouseEvent e) + public void mouseClicked(final MouseEvent e) { - int xShift = innerFlowPane.getLocationOnScreen().x - getLocationOnScreen().x; - int yShift = innerFlowPane.getLocationOnScreen().y - getLocationOnScreen().y; - Point realPoint = new Point(e.getX() + xShift, e.getY() + yShift); + final int xShift = innerFlowPane.getLocationOnScreen().x - getLocationOnScreen().x; + final int yShift = innerFlowPane.getLocationOnScreen().y - getLocationOnScreen().y; + final Point realPoint = new Point(e.getX() + xShift, e.getY() + yShift); - for (Var<?> var : exposingLinks.keySet()) + for (final Var<?> var : exposingLinks.keySet()) if (exposingLinks.get(var).isOverCloseButton(realPoint)) { VarList vars = blockDesc.inputVars; @@ -84,13 +84,13 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener } @Override - public void mouseMoved(MouseEvent e) + public void mouseMoved(final MouseEvent e) { - int xShift = innerFlowPane.getLocationOnScreen().x - getLocationOnScreen().x; - int yShift = innerFlowPane.getLocationOnScreen().y - getLocationOnScreen().y; - Point realPoint = new Point(e.getX() + xShift, e.getY() + yShift); + final int xShift = innerFlowPane.getLocationOnScreen().x - getLocationOnScreen().x; + final int yShift = innerFlowPane.getLocationOnScreen().y - getLocationOnScreen().y; + final Point realPoint = new Point(e.getX() + xShift, e.getY() + yShift); - for (Line l : exposingLinks.values()) + for (final Line l : exposingLinks.values()) l.setCustomColor(l.contains(realPoint.x, realPoint.y)); } }; @@ -115,7 +115,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener add(varBox, BorderLayout.SOUTH); // check whether the descriptor has a stored size - Dimension size = innerWorkFlow.getBlockDescriptor().getDimension(); + final Dimension size = innerWorkFlow.getBlockDescriptor().getDimension(); if (size.width != 0) { @@ -136,7 +136,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener } @Override - public void actionPerformed(ActionEvent e) + public void actionPerformed(final ActionEvent e) { if (e.getSource() == menuRemoveEnclosure) { @@ -159,22 +159,24 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener @Override protected void drawContent() { - int maxRow = drawExposedLinks(0); + final int maxRow = drawExposedLinks(0); drawInnerWorkFlowContainer(maxRow + 1); } /** - * Draws the drag'n'drop zones representing the exposed variables of the inner work flow - * - * @param gridRow - * the row where to start drawing within the {@link GridBagLayout} - * @return the last row used in the {@link GridBagLayout} - */ - protected int drawExposedLinks(int row) + * Draws the drag'n'drop zones representing the exposed variables of the + * inner work flow + * + * @param row + * the row where to start drawing within the + * {@link GridBagLayout} + * @return the last row used in the {@link GridBagLayout} + */ + protected int drawExposedLinks(final int row) { int rowIn = row; - for (Var<?> input : innerWorkFlow.getBlockDescriptor().inputVars) + for (final Var<?> input : innerWorkFlow.getBlockDescriptor().inputVars) { // don't show hidden variable if (!blockDesc.inputVars.isVisible(input)) @@ -187,19 +189,19 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener if (!varDropZones.containsKey(input)) varDropZones.put(input, createVarDropZone(input, true, DragDropZone.LINK_RIGHT)); - GridBagConstraints gbc_dropZone = new GridBagConstraints(); + final GridBagConstraints gbc_dropZone = new GridBagConstraints(); gbc_dropZone.anchor = GridBagConstraints.WEST; gbc_dropZone.fill = GridBagConstraints.NONE; gbc_dropZone.insets = new Insets(2, 0, 0, 0); gbc_dropZone.gridx = 0; gbc_dropZone.gridy = rowIn++; gbc_dropZone.weighty = 0; - DragDropZone dropZone = varDropZones.get(input); + final DragDropZone dropZone = varDropZones.get(input); jPanelContent.add(dropZone, gbc_dropZone); } int rowOut = row; - for (Var<?> output : innerWorkFlow.getBlockDescriptor().outputVars) + for (final Var<?> output : innerWorkFlow.getBlockDescriptor().outputVars) { // don't show hidden variable if (!blockDesc.outputVars.isVisible(output)) @@ -212,13 +214,13 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener if (!varDragZones.containsKey(output)) varDragZones.put(output, createVarDragZone(output, true)); - GridBagConstraints gbc_dragZone = new GridBagConstraints(); + final GridBagConstraints gbc_dragZone = new GridBagConstraints(); gbc_dragZone.anchor = GridBagConstraints.EAST; gbc_dragZone.fill = GridBagConstraints.NONE; gbc_dragZone.insets = new Insets(2, 0, 0, 0); gbc_dragZone.gridx = 0; gbc_dragZone.gridy = rowOut++; - DragDropZone dragZone = varDragZones.get(output); + final DragDropZone dragZone = varDragZones.get(output); jPanelContent.add(dragZone, gbc_dragZone); } @@ -231,9 +233,9 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener * @param row * the row where the container should be added within the {@link GridBagLayout} */ - protected void drawInnerWorkFlowContainer(int row) + protected void drawInnerWorkFlowContainer(final int row) { - GridBagConstraints gbc = new GridBagConstraints(); + final GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(0, 15, 5, 13); gbc.anchor = GridBagConstraints.CENTER; gbc.gridx = 0; @@ -262,16 +264,16 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener } @Override - public void paintChildren(Graphics g) + public void paintChildren(final Graphics g) { - Graphics gg = g.create(); + final Graphics gg = g.create(); super.paintChildren(g); - Rectangle clip = scrollPane.getBounds(); + final Rectangle clip = scrollPane.getBounds(); gg.clipRect(clip.x, clip.y, clip.width, clip.height); if (!blockDesc.isCollapsed()) - for (Line line : exposingLinks.values()) + for (final Line line : exposingLinks.values()) { line.update(); line.paint((Graphics2D) gg); @@ -281,7 +283,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener } @Override - public void visibilityChanged(final Var<?> variable, boolean isVisible) + public void visibilityChanged(final Var<?> variable, final boolean isVisible) { // Refresh first to ensure all existing blocks and links are visible ThreadUtil.invokeNow(new Runnable() @@ -296,7 +298,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener updateExposedLink(variable, isVisible); } - public void updateExposedLink(final Var<?> variable, boolean visible) + public void updateExposedLink(final Var<?> variable, final boolean visible) { if (visible) { @@ -307,7 +309,8 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener ThreadUtil.invokeLater(new Runnable() { - public void run() + @Override + public void run() { final BlockPanel ownerPanel = innerFlowPane.getBlockPanel(innerBlock); @@ -334,12 +337,12 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener if (blockDesc.isCollapsed()) return; - DragDropZone dz = getP1Zone(); + final DragDropZone dz = getP1Zone(); if (dz != null) { - int y = dz.getLocationOnScreen().y; - int offsetY = getLocationOnScreen().y; + final int y = dz.getLocationOnScreen().y; + final int offsetY = getLocationOnScreen().y; x1 = dz.getWidth(); y1 = y - offsetY + dz.getHeight() / 2; @@ -351,14 +354,14 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener { if (ownerPanel.blockDesc.isCollapsed()) { - Point loc = ownerPanel.getLocationOnScreen(); + final Point loc = ownerPanel.getLocationOnScreen(); x2 = loc.x - getLocationOnScreen().x + SHADOW_SIZE; y2 = loc.y - getLocationOnScreen().y + ownerPanel.getHeight() / 2; } else { - DragDropZone dz = ownerPanel.varDropZones.get(variable); - Point loc = dz.getLocationOnScreen(); + final DragDropZone dz = ownerPanel.varDropZones.get(variable); + final Point loc = dz.getLocationOnScreen(); x2 = loc.x - getLocationOnScreen().x; y2 = loc.y - getLocationOnScreen().y + dz.getHeight() / 2; } @@ -374,7 +377,8 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener ThreadUtil.invokeLater(new Runnable() { - public void run() + @Override + public void run() { final BlockPanel ownerPanel = innerFlowPane.getBlockPanel(innerBlock); @@ -400,14 +404,14 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener { if (ownerPanel.blockDesc.isCollapsed()) { - Point loc = ownerPanel.getLocationOnScreen(); + final Point loc = ownerPanel.getLocationOnScreen(); x1 = loc.x - getLocationOnScreen().x + ownerPanel.getWidth() - SHADOW_SIZE; y1 = loc.y - getLocationOnScreen().y + ownerPanel.getHeight() / 2; } else { - DragDropZone dz = ownerPanel.varDragZones.get(variable); - Point loc = dz.getLocationOnScreen(); + final DragDropZone dz = ownerPanel.varDragZones.get(variable); + final Point loc = dz.getLocationOnScreen(); x1 = loc.x - getLocationOnScreen().x + dz.getWidth(); y1 = loc.y - getLocationOnScreen().y + dz.getHeight() / 2; } @@ -419,9 +423,9 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener if (blockDesc.isCollapsed()) return; - DragDropZone dz = varDragZones.get(variable); - int y = dz.getLocationOnScreen().y; - int innerY = getLocationOnScreen().y; + final DragDropZone dz = varDragZones.get(variable); + final int y = dz.getLocationOnScreen().y; + final int innerY = getLocationOnScreen().y; x2 = dz.getLocation().x; y2 = y - innerY + dz.getHeight() / 2; @@ -439,7 +443,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener BlockDescriptor block = innerWorkFlow.getInputOwner(variable); - WorkFlow parentWorkFlow = blockDesc.getContainer(); + final WorkFlow parentWorkFlow = blockDesc.getContainer(); if (block != null) { @@ -461,12 +465,12 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener blockDesc.getContainer().getBlockDescriptor().removeOutput(variable); // remove links pointed to the exposed variable (if any) - ArrayList<Link<?>> linksToDelete = new ArrayList<Link<?>>(); - for (Link<?> link : parentWorkFlow.getLinksIterator()) + final ArrayList<Link<?>> linksToDelete = new ArrayList<Link<?>>(); + for (final Link<?> link : parentWorkFlow.getLinksIterator()) if (link.srcVar == variable) linksToDelete.add(link); - for (Link<?> link : linksToDelete) + for (final Link<?> link : linksToDelete) parentWorkFlow.removeLink(link.dstVar); } } @@ -477,33 +481,34 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener getParent().repaint(); } - public void drawPanel() + @Override + public void drawPanel() { super.drawPanel(); varBox.setVisible(blockDesc.isCollapsed()); if (blockDesc.isCollapsed()) { - GridBagConstraints gbc_dropZone = new GridBagConstraints(); + final GridBagConstraints gbc_dropZone = new GridBagConstraints(); gbc_dropZone.anchor = GridBagConstraints.WEST; gbc_dropZone.fill = GridBagConstraints.NONE; gbc_dropZone.insets = new Insets(2, 0, 0, 0); gbc_dropZone.gridx = 0; - GridBagConstraints gbc_varName = new GridBagConstraints(); + final GridBagConstraints gbc_varName = new GridBagConstraints(); gbc_varName.anchor = GridBagConstraints.CENTER; gbc_varName.fill = GridBagConstraints.HORIZONTAL; gbc_varName.insets = new Insets(2, 5, 0, 0); gbc_varName.gridx = 1; gbc_varName.weightx = 1; - GridBagConstraints gbc_dragZone = new GridBagConstraints(); + final GridBagConstraints gbc_dragZone = new GridBagConstraints(); gbc_dragZone.anchor = GridBagConstraints.EAST; gbc_dragZone.fill = GridBagConstraints.NONE; gbc_dragZone.insets = new Insets(2, 5, 0, 0); gbc_dragZone.gridx = 2; - LinkedHashMap<BlockDescriptor, ArrayList<Var<?>>> inputs = new LinkedHashMap<BlockDescriptor, ArrayList<Var<?>>>(); - LinkedHashMap<BlockDescriptor, ArrayList<Var<?>>> outputs = new LinkedHashMap<BlockDescriptor, ArrayList<Var<?>>>(); + final LinkedHashMap<BlockDescriptor, ArrayList<Var<?>>> inputs = new LinkedHashMap<BlockDescriptor, ArrayList<Var<?>>>(); + final LinkedHashMap<BlockDescriptor, ArrayList<Var<?>>> outputs = new LinkedHashMap<BlockDescriptor, ArrayList<Var<?>>>(); JPanel blockP; Box blockBox; @@ -516,12 +521,12 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener int nbExposingBlocks = 0; - for (BlockDescriptor bd : innerWorkFlow) + for (final BlockDescriptor bd : innerWorkFlow) { in = new ArrayList<Var<?>>(); out = new ArrayList<Var<?>>(); - for (Var<?> v : bd.inputVars) + for (final Var<?> v : bd.inputVars) if (exposingLinks.keySet().contains(v)) { in.add(v); @@ -532,7 +537,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener nbExposingBlocks++; } } - for (Var<?> v : bd.outputVars) + for (final Var<?> v : bd.outputVars) if (exposingLinks.keySet().contains(v)) { out.add(v); @@ -547,13 +552,13 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener varBox.setPreferredSize(new Dimension(0, exposingLinks.size() * 20 + nbExposingBlocks * 25)); - for (BlockDescriptor bd : inputs.keySet()) + for (final BlockDescriptor bd : inputs.keySet()) { varBox.add(new JSeparator(JSeparator.HORIZONTAL)); blockP = new JPanel(new BorderLayout()); blockP.setOpaque(false); - JLabel blockName = new JLabel("\t" + bd.getDefinedName(), JLabel.CENTER); + final JLabel blockName = new JLabel("\t" + bd.getDefinedName(), JLabel.CENTER); blockName.setFont(blockName.getFont().deriveFont(Font.BOLD + Font.ITALIC, 12)); blockP.add(blockName, BorderLayout.NORTH); @@ -561,7 +566,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener blockBox.setOpaque(false); blockP.add(blockBox, BorderLayout.CENTER); - for (Var<?> v : inputs.get(bd)) + for (final Var<?> v : inputs.get(bd)) { varPanel = new JPanel(new GridBagLayout()); varPanel.setOpaque(false); @@ -572,7 +577,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener blockBox.add(varPanel); } - for (Var<?> v : outputs.get(bd)) + for (final Var<?> v : outputs.get(bd)) { varPanel = new JPanel(new GridBagLayout()); varPanel.setOpaque(false); @@ -590,9 +595,10 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener } } - public Dimension getPreferredSize() + @Override + public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); + final Dimension d = super.getPreferredSize(); if (!blockDesc.isCollapsed()) return d; diff --git a/src/main/java/plugins/adufour/protocols/gui/link/DragDropZone.java b/src/main/java/plugins/adufour/protocols/gui/link/DragDropZone.java index b7319cbdab7f2cd580474defdad6a65d83804cfd..8e041fd298f443c7e2224fadcae7d54250d7b1b4 100644 --- a/src/main/java/plugins/adufour/protocols/gui/link/DragDropZone.java +++ b/src/main/java/plugins/adufour/protocols/gui/link/DragDropZone.java @@ -42,7 +42,7 @@ public abstract class DragDropZone extends JButton implements VarListener<Boolea private final Var<?> variable; - private int iconSize = DEFAULT_ICON_SIZE; + private final int iconSize = DEFAULT_ICON_SIZE; private Icon defaultIcon; @@ -53,15 +53,13 @@ public abstract class DragDropZone extends JButton implements VarListener<Boolea /** * Creates a new drop zone for the given variable * - * @param flowPane - * the flow pane where variable links will come from * @param block * the box that owns the specified input * @param input * the input variable to link to * @return */ - public static <T> DragDropZone createDropZone(Image image, WorkFlow workFlow, BlockDescriptor block, Var<T> input) + public static <T> DragDropZone createDropZone(final Image image, final WorkFlow workFlow, final BlockDescriptor block, final Var<T> input) { return new DropZone<T>(image, workFlow, block, input); } @@ -77,13 +75,13 @@ public abstract class DragDropZone extends JButton implements VarListener<Boolea * the input variable to link * @return */ - public static <T> DragDropZone createDragZone(Image image, WorkFlow workFlow, BlockDescriptor block, - Var<T> variable) + public static <T> DragDropZone createDragZone(final Image image, final WorkFlow workFlow, final BlockDescriptor block, + final Var<T> variable) { return new DragZone<T>(image, workFlow, block, variable); } - protected DragDropZone(String toolTipText, Image image, Var<?> variable) + protected DragDropZone(final String toolTipText, final Image image, final Var<?> variable) { super(""); this.variable = variable; @@ -117,7 +115,7 @@ public abstract class DragDropZone extends JButton implements VarListener<Boolea { if (variable instanceof VarGenericArray) { - VarGenericArray<?> array = (VarGenericArray<?>) variable; + final VarGenericArray<?> array = (VarGenericArray<?>) variable; dataType = array.getInnerType(); } else if (dataType.isArray()) @@ -129,10 +127,10 @@ public abstract class DragDropZone extends JButton implements VarListener<Boolea defaultIcon = getLinkIcon(getColor(dataType)); } - public Icon getLinkIcon(Color color) + public Icon getLinkIcon(final Color color) { - Image myImage = new BufferedImage(iconSize, iconSize, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = (Graphics2D) myImage.getGraphics(); + final Image myImage = new BufferedImage(iconSize, iconSize, BufferedImage.TYPE_INT_ARGB); + final Graphics2D g = (Graphics2D) myImage.getGraphics(); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); @@ -142,7 +140,7 @@ public abstract class DragDropZone extends JButton implements VarListener<Boolea // draw the white arrow g.setColor(Color.white); - Path2D.Float arrow = new Path2D.Float(); + final Path2D.Float arrow = new Path2D.Float(); arrow.moveTo(2.5f, 5); arrow.lineTo(6, 5); arrow.lineTo(6, 2.5f); @@ -170,7 +168,7 @@ public abstract class DragDropZone extends JButton implements VarListener<Boolea setIcon(errorIcon); } - public void setIconSize(int size) + public void setIconSize(final int size) { // this.iconSize = size; setDefaultLinkIcon(); @@ -183,26 +181,26 @@ public abstract class DragDropZone extends JButton implements VarListener<Boolea } @Override - public void valueChanged(Var<Boolean> source, Boolean oldValue, Boolean newValue) + public void valueChanged(final Var<Boolean> source, final Boolean oldValue, final Boolean newValue) { setDefaultLinkIcon(); } @Override - public void referenceChanged(Var<Boolean> source, Var<? extends Boolean> oldReference, - Var<? extends Boolean> newReference) + public void referenceChanged(final Var<Boolean> source, final Var<? extends Boolean> oldReference, + final Var<? extends Boolean> newReference) { setDefaultLinkIcon(); } @Override - public void typeChanged(Object source, Class<?> oldType, Class<?> newType) + public void typeChanged(final Object source, final Class<?> oldType, final Class<?> newType) { updateDefaultIcon(); setDefaultLinkIcon(); } - public static Color getColor(Class<?> type) + public static Color getColor(final Class<?> type) { if (type == null) return Color.gray; diff --git a/src/main/java/plugins/adufour/protocols/gui/link/Line.java b/src/main/java/plugins/adufour/protocols/gui/link/Line.java index a7e45ebf199812544da851848cd2b461bed1e78b..789b39ad32932b69bfdfd6210ce69fb3183d136a 100644 --- a/src/main/java/plugins/adufour/protocols/gui/link/Line.java +++ b/src/main/java/plugins/adufour/protocols/gui/link/Line.java @@ -48,7 +48,7 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo private boolean isSelected = false; - private Stroke selectedStroke = new BasicStroke(8); + private final Stroke selectedStroke = new BasicStroke(8); /** * Creates a line representing a link between two variables @@ -62,7 +62,7 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo * @throws IllegalArgumentException * if the <code>link</code> argument is <code>null</code> */ - public Line(BlockPanel srcPanel, BlockPanel dstPanel, Link<?> link) throws IllegalArgumentException + public Line(final BlockPanel srcPanel, final BlockPanel dstPanel, final Link<?> link) throws IllegalArgumentException { if (link == null) throw new IllegalArgumentException("link cannot be null"); @@ -90,7 +90,7 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo * @param exposedVariable * the exposed variable */ - public Line(BlockPanel srcPanel, BlockPanel dstPanel, Var<?> exposedVariable) + public Line(final BlockPanel srcPanel, final BlockPanel dstPanel, final Var<?> exposedVariable) { this.link = null; this.srcPanel = srcPanel; @@ -129,22 +129,28 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo } /** - * @return the drag'drop zone corresponding to the first extremity of this line. This method is - * called once when creating the line, in order to attach a mouse listener to the - * drag'n'drop zone to support line coloring<br/> - * NOTE: This method *must* be overridden if this line is not backed by a non-null link. - */ + * @return the drag'drop zone corresponding to the first extremity of this + * line. This method is called once when creating the line, in order + * to attach a mouse listener to the drag'n'drop zone to support + * line coloring + * <p> + * NOTE: This method *must* be overridden if this line is not backed + * by a non-null link. + */ protected DragDropZone getP1Zone() { return srcPanel.getDragZone(link.srcVar); } /** - * @return the drag'drop zone corresponding to the second extremity of this line. This method is - * called once when creating the line, in order to attach a mouse listener to the - * drag'n'drop zone to support line coloring<br/> - * NOTE: This method *must* be overridden if this line is not backed by a non-null link. - */ + * @return the drag'drop zone corresponding to the second extremity of this + * line. This method is called once when creating the line, in order + * to attach a mouse listener to the drag'n'drop zone to support + * line coloring + * <p> + * NOTE: This method *must* be overridden if this line is not backed + * by a non-null link. + */ protected DragDropZone getP2Zone() { return dstPanel.getDropZone(link.dstVar); @@ -152,14 +158,14 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo protected void updateP1() { - Point loc = srcPanel.getDragZoneLocation(link.srcVar); + final Point loc = srcPanel.getDragZoneLocation(link.srcVar); x1 = loc.x; y1 = loc.y; } protected void updateP2() { - Point loc = dstPanel.getDropZoneLocation(link.dstVar); + final Point loc = dstPanel.getDropZoneLocation(link.dstVar); x2 = loc.x; y2 = loc.y; } @@ -172,7 +178,7 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo */ public abstract void updateShape(Path2D thePath, Ellipse2D theCloseButton); - public void paint(Graphics2D g) + public void paint(final Graphics2D g) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); @@ -194,9 +200,9 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo paintCloseButton(g); } - private void paintCloseButton(Graphics g) + private void paintCloseButton(final Graphics g) { - Graphics2D g2 = (Graphics2D) g.create(); + final Graphics2D g2 = (Graphics2D) g.create(); g2.fill(closeButton); g2.setColor(Color.white); g2.drawLine((int) closeButton.x + 4, (int) closeButton.y + 4, (int) closeButton.x + 8, (int) closeButton.y + 8); @@ -204,9 +210,9 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo g2.dispose(); } - protected void updateCloseButtonShape(Shape s) + protected void updateCloseButtonShape(final Shape s) { - Rectangle r = s.getBounds(); + final Rectangle r = s.getBounds(); closeButton.setFrame(r.x + r.width / 2 - 6, r.y + r.height / 2 - 6, 13, 13); } @@ -218,7 +224,7 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo * the point to check * @return true if p is within the virtual close button, false otherwise */ - public boolean isOverCloseButton(Point p) + public boolean isOverCloseButton(final Point p) { return isOverCloseButton(p.x, p.y); } @@ -227,19 +233,17 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo * Indicates if the location p is inside the virtual close button. This method can be used to * check whether the user has clicked on the close button * - * @param p - * the point to check * @return true if p is within the virtual close button, false otherwise */ - public boolean isOverCloseButton(double x, double y) + public boolean isOverCloseButton(final double x, final double y) { return closeButton.contains(x, y); } public void dispose() { - DragDropZone p1 = getP1Zone(); - DragDropZone p2 = getP2Zone(); + final DragDropZone p1 = getP1Zone(); + final DragDropZone p2 = getP2Zone(); if (p1 != null) p1.removeMouseListener(this); // TODO leak ? if (p2 != null) @@ -250,50 +254,50 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo } @Override - public void componentHidden(ComponentEvent arg0) + public void componentHidden(final ComponentEvent arg0) { } @Override - public void componentMoved(ComponentEvent arg0) + public void componentMoved(final ComponentEvent arg0) { updateLine((BlockPanel) arg0.getSource()); } @Override - public void componentResized(ComponentEvent arg0) + public void componentResized(final ComponentEvent arg0) { updateLine((BlockPanel) arg0.getSource()); } @Override - public void componentShown(ComponentEvent arg0) + public void componentShown(final ComponentEvent arg0) { } @Override - public void mouseClicked(MouseEvent e) + public void mouseClicked(final MouseEvent e) { } @Override - public void mousePressed(MouseEvent e) + public void mousePressed(final MouseEvent e) { } @Override - public void mouseReleased(MouseEvent e) + public void mouseReleased(final MouseEvent e) { } @Override - public void mouseEntered(MouseEvent e) + public void mouseEntered(final MouseEvent e) { setCustomColor(true); } @Override - public void mouseExited(MouseEvent e) + public void mouseExited(final MouseEvent e) { setCustomColor(false); } @@ -305,7 +309,7 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo * * @param custom */ - public void setCustomColor(boolean custom) + public void setCustomColor(final boolean custom) { isHighlighted = custom; srcPanel.getWorkFlowContainer().repaint(); @@ -324,11 +328,11 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo updateP1(); updateP2(); } - catch (IllegalComponentStateException e) + catch (final IllegalComponentStateException e) { } - catch (NullPointerException e) + catch (final NullPointerException e) { } @@ -336,7 +340,7 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo }); } - private void updateLine(BlockPanel panel) + private void updateLine(final BlockPanel panel) { if (panel == srcPanel) { @@ -348,7 +352,7 @@ public abstract class Line extends Line2D.Float implements ComponentListener, Mo } } - public void setSelected(boolean selected) + public void setSelected(final boolean selected) { isSelected = selected; }