From 6c037e5f6919b7cc73e6bf442896aaef26f032f9 Mon Sep 17 00:00:00 2001 From: Alois Zoitl Date: Mon, 31 Jul 2023 20:23:14 +0200 Subject: [PATCH] more clean-up of draw2d examples --- .../eclipse/draw2d/examples/ExampleUtil.java | 23 +++++++++------- .../eclipse/draw2d/examples/HelloWorld.java | 15 ++++++----- .../examples/cg/ObstructionExample.java | 5 ++-- .../ConnectionAndAnchorExample.java | 7 +++-- .../examples/graph/AbstractGraphDemo.java | 26 ++++++++----------- .../examples/graph/CompoundGraphDemo.java | 9 ++++--- .../examples/graph/DirectedGraphDemo.java | 2 +- .../examples/layouts/FlowLayoutExample.java | 25 +++++++++--------- .../draw2d/examples/path/PathFigure.java | 13 +++++----- .../examples/scrollpane/InternalFrame.java | 5 ++-- .../swt/InheritBackgroundExample.java | 7 ++--- .../examples/text/BidiBlockExample.java | 13 +++++----- .../examples/text/MultiLineLabelExample.java | 3 ++- .../draw2d/examples/text/TextFlowExample.java | 16 +++++++----- .../draw2d/examples/tree/Animation.java | 2 +- .../draw2d/examples/tree/TreeBranch.java | 18 +++++-------- .../draw2d/examples/tree/TreeRoot.java | 5 +--- .../draw2d/examples/uml/UMLClassDiagram.java | 11 ++++---- 18 files changed, 106 insertions(+), 99 deletions(-) diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/ExampleUtil.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/ExampleUtil.java index 4df5e8514..2638e65eb 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/ExampleUtil.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/ExampleUtil.java @@ -10,48 +10,51 @@ *******************************************************************************/ package org.eclipse.draw2d.examples; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; + import org.eclipse.draw2d.Figure; import org.eclipse.draw2d.FlowLayout; import org.eclipse.draw2d.GroupBoxBorder; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; /** * A factory for figures. Created on :Sep 26, 2002 - * + * * @author hudsonr * @since 2.0 */ public final class ExampleUtil { - static final Font FONT_LARGE = new Font(null, "Arial", 16, SWT.BOLD); + static final Font FONT_LARGE = new Font(null, "Arial", 16, SWT.BOLD); //$NON-NLS-1$ public static IFigure createFlowLayoutPanel() { Figure f = new Figure(); - f.setBorder(new GroupBoxBorder("FlowLayout")); + f.setBorder(new GroupBoxBorder("FlowLayout")); //$NON-NLS-1$ f.setLayoutManager(new FlowLayout()); - for (int i = 0; i < 5; i++) - f.add(new Label("Label " + i, ExampleImages.GEORGE)); + for (int i = 0; i < 5; i++) { + f.add(new Label("Label " + i, ExampleImages.GEORGE)); //$NON-NLS-1$ + } // Label l = new Label("A really wide label is here"); // l.setBorder(new LineBorder()); // l.setFont(FONT_LARGE); // f.add(l); - for (int i = 6; i < 10; i++) - f.add(new Label("Label " + i, ExampleImages.GEORGE)); + for (int i = 6; i < 10; i++) { + f.add(new Label("Label " + i, ExampleImages.GEORGE)); //$NON-NLS-1$ + } return f; } public static IFigure createToolbarLayout() { Figure f = new Figure(); - f.setBorder(new GroupBoxBorder("Toolbar")); + f.setBorder(new GroupBoxBorder("Toolbar")); //$NON-NLS-1$ f.setLayoutManager(new ToolbarLayout()); f.add(createFlowLayoutPanel()); f.add(createFlowLayoutPanel()); diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/HelloWorld.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/HelloWorld.java index 73e08cb5c..d26db8837 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/HelloWorld.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/HelloWorld.java @@ -10,12 +10,13 @@ *******************************************************************************/ package org.eclipse.draw2d.examples; -import org.eclipse.draw2d.FigureCanvas; -import org.eclipse.draw2d.Label; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.eclipse.draw2d.FigureCanvas; +import org.eclipse.draw2d.Label; + public class HelloWorld { public static void main(String[] args) { @@ -25,14 +26,16 @@ public static void main(String[] args) { shell.setLayout(new FillLayout()); FigureCanvas canvas = new FigureCanvas(shell); - canvas.setContents(new Label("Hello World")); + canvas.setContents(new Label("Hello World")); //$NON-NLS-1$ - shell.setText("Draw2d"); + shell.setText("Draw2d"); //$NON-NLS-1$ shell.setSize(200, 100); shell.open(); - while (!shell.isDisposed()) - while (!d.readAndDispatch()) + while (!shell.isDisposed()) { + while (!d.readAndDispatch()) { d.sleep(); + } + } } diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/cg/ObstructionExample.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/cg/ObstructionExample.java index 3915af43b..2d924fd77 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/cg/ObstructionExample.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/cg/ObstructionExample.java @@ -150,9 +150,9 @@ public void paint(Graphics graphics) { super.paint(graphics); Rectangle b = getBounds(); Point p = b.getCenter().translate(-22, -15); - graphics.drawString("y:" + b.y() + "h:" + b.height(), p); + graphics.drawString("y:" + b.y() + "h:" + b.height(), p); //$NON-NLS-1$ //$NON-NLS-2$ p.setY(p.y() + 12); - graphics.drawString("x:" + b.x() + "w:" + b.width(), p); + graphics.drawString("x:" + b.x() + "w:" + b.width(), p); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -160,7 +160,6 @@ class TestFigure extends Figure { private static final int INITAL_OBSTACLE_COUNT = 5; - Map obstacleMap = new HashMap(); boolean showSegs = false; public TestFigure() { diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/connections/ConnectionAndAnchorExample.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/connections/ConnectionAndAnchorExample.java index 750f4e01e..5b01bf952 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/connections/ConnectionAndAnchorExample.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/connections/ConnectionAndAnchorExample.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.draw2d.examples.connections; +import org.eclipse.swt.widgets.Shell; + import org.eclipse.draw2d.ChopboxAnchor; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.ConnectionEndpointLocator; @@ -129,9 +131,10 @@ protected IFigure createContents() { } /** - * @see org.eclipse.draw2d.examples.AbstractExample#hookShell() + * @see org.eclipse.draw2d.examples.AbstractExample#hookShell(Shell shell) */ - protected void hookShell() { + @Override + protected void hookShell(Shell shell) { getFigureCanvas().setSize(820, 440); } diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/AbstractGraphDemo.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/AbstractGraphDemo.java index 4157a9a40..053041f85 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/AbstractGraphDemo.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/AbstractGraphDemo.java @@ -13,6 +13,16 @@ import java.util.ArrayList; import java.util.List; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + import org.eclipse.draw2d.AbsoluteBendpoint; import org.eclipse.draw2d.BendpointConnectionRouter; import org.eclipse.draw2d.ChopboxAnchor; @@ -30,15 +40,6 @@ import org.eclipse.draw2d.graph.Edge; import org.eclipse.draw2d.graph.Node; import org.eclipse.draw2d.graph.NodeList; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; /** * @author Daniel Lee @@ -184,9 +185,7 @@ static PolylineConnection connection(Edge e) { return conn; } - /** - * @see org.eclipse.graph.AbstractExample#createContents() - */ + @SuppressWarnings("static-method") protected IFigure getContents() { return null; } @@ -208,9 +207,6 @@ protected FigureCanvas getFigureCanvas() { */ protected abstract String[] getGraphMethods(); - /** - * @see org.eclipse.graph.AbstractExample#hookShell() - */ protected void hookShell() { Composite composite = new Composite(shell, 0); composite.setLayoutData(new GridData(GridData.FILL_VERTICAL)); diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/CompoundGraphDemo.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/CompoundGraphDemo.java index ec3c61ce2..a20f530a7 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/CompoundGraphDemo.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/CompoundGraphDemo.java @@ -12,6 +12,8 @@ import java.lang.reflect.Method; +import org.eclipse.swt.graphics.Font; + import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Figure; import org.eclipse.draw2d.IFigure; @@ -23,7 +25,6 @@ import org.eclipse.draw2d.graph.Edge; import org.eclipse.draw2d.graph.Node; import org.eclipse.draw2d.graph.Subgraph; -import org.eclipse.swt.graphics.Font; /** * @author hudsonr @@ -39,7 +40,7 @@ public class CompoundGraphDemo extends AbstractGraphDemo { */ public static Figure buildGraph(CompoundDirectedGraph graph) { Figure contents = new Panel(); - contents.setFont(new Font(null, "Tahoma", 10, 0)); + contents.setFont(new Font(null, "Tahoma", 10, 0)); //$NON-NLS-1$ contents.setBackgroundColor(ColorConstants.white); contents.setLayoutManager(new XYLayout()); @@ -134,13 +135,13 @@ protected IFigure getContents() { graph = (CompoundDirectedGraph) (CompoundGraphTests.class.getMethod(graphMethod, int.class).invoke(null, Integer.valueOf(graphDirection))); } catch (Exception e) { - System.out.println("Could not build graph"); + System.out.println("Could not build graph"); //$NON-NLS-1$ } return buildGraph(graph); } /** - * @see org.eclipse.graph.demo.GraphDemo#getGraphMethods() + * @see org.eclipse.draw2d.examples.graph.AbstractGraphDemo#getGraphMethods() */ @Override protected String[] getGraphMethods() { diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/DirectedGraphDemo.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/DirectedGraphDemo.java index 314899b5b..ecce0ba60 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/DirectedGraphDemo.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/graph/DirectedGraphDemo.java @@ -124,7 +124,7 @@ public static void main(String[] args) { } /** - * @see org.eclipse.graph.demo.GraphDemo#getGraphMethods() + * @see org.eclipse.draw2d.examples.graph.AbstractGraphDemo#getGraphMethods() */ @Override protected String[] getGraphMethods() { diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/layouts/FlowLayoutExample.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/layouts/FlowLayoutExample.java index b01295f1a..40dabcc36 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/layouts/FlowLayoutExample.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/layouts/FlowLayoutExample.java @@ -10,17 +10,6 @@ *******************************************************************************/ package org.eclipse.draw2d.examples.layouts; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Ellipse; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.FlowLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.draw2d.OrderedLayout; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.RoundedRectangle; -import org.eclipse.draw2d.Triangle; -import org.eclipse.draw2d.examples.AbstractExample; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -34,6 +23,18 @@ import org.eclipse.swt.widgets.Scale; import org.eclipse.swt.widgets.Shell; +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.Ellipse; +import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.FlowLayout; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.LineBorder; +import org.eclipse.draw2d.OrderedLayout; +import org.eclipse.draw2d.RectangleFigure; +import org.eclipse.draw2d.RoundedRectangle; +import org.eclipse.draw2d.Triangle; +import org.eclipse.draw2d.examples.AbstractExample; + /** * @author hudsonr Created on Apr 30, 2003 */ @@ -124,7 +125,7 @@ protected IFigure createContents() { } /** - * @see org.eclipse.draw2d.examples.AbstractExample#hookShell() + * @see org.eclipse.draw2d.examples.AbstractExample#hookShell(Shell shell) */ @Override protected void hookShell(Shell shell) { diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/path/PathFigure.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/path/PathFigure.java index 4414ac320..514e17810 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/path/PathFigure.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/path/PathFigure.java @@ -10,6 +10,12 @@ *******************************************************************************/ package org.eclipse.draw2d.examples.path; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Path; +import org.eclipse.swt.graphics.TextLayout; +import org.eclipse.swt.graphics.TextStyle; +import org.eclipse.swt.widgets.Display; + import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.Polyline; @@ -18,11 +24,6 @@ import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.PrecisionPoint; import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Path; -import org.eclipse.swt.graphics.TextLayout; -import org.eclipse.swt.graphics.TextStyle; -import org.eclipse.swt.widgets.Display; public class PathFigure extends Polyline { @@ -65,7 +66,7 @@ private void drawShape(Graphics g, boolean fill) { TextLayout textLayout = new TextLayout(Display.getDefault()); textLayout.setFont(g.getFont()); - textLayout.setText("zoom" + (g instanceof ScaledGraphics ? "[e]" : "[n]")); + textLayout.setText("zoom" + (g instanceof ScaledGraphics ? "[e]" : "[n]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ TextStyle textStyle = new TextStyle(); textStyle.underline = true; textStyle.underlineColor = ColorConstants.blue; diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/scrollpane/InternalFrame.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/scrollpane/InternalFrame.java index e9a964d51..44706ce8d 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/scrollpane/InternalFrame.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/scrollpane/InternalFrame.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.draw2d.examples.scrollpane; +import org.eclipse.swt.graphics.Cursor; + import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.CompoundBorder; import org.eclipse.draw2d.Cursors; @@ -26,7 +28,6 @@ import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Cursor; public class InternalFrame extends LabeledContainer { @@ -113,7 +114,7 @@ public void mouseMoved(MouseEvent me) { Rectangle figBounds = getBounds(); Point mouseLocation = me.getLocation(); if (!getBounds().contains(mouseLocation)) { - System.out.println("Error"); + System.out.println("Error"); //$NON-NLS-1$ } if (!figBounds.contains(mouseLocation)) { return; diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/swt/InheritBackgroundExample.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/swt/InheritBackgroundExample.java index 87d081c29..45b176ed1 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/swt/InheritBackgroundExample.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/swt/InheritBackgroundExample.java @@ -10,9 +10,6 @@ *******************************************************************************/ package org.eclipse.draw2d.examples.swt; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.FigureCanvas; -import org.eclipse.draw2d.Label; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; @@ -24,6 +21,10 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Shell; +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.FigureCanvas; +import org.eclipse.draw2d.Label; + public class InheritBackgroundExample { static Shell shell; diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/BidiBlockExample.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/BidiBlockExample.java index 85fd98a6d..a5b88dc15 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/BidiBlockExample.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/BidiBlockExample.java @@ -9,17 +9,18 @@ package org.eclipse.draw2d.examples.text; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + import org.eclipse.draw2d.FigureCanvas; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.text.BlockFlow; import org.eclipse.draw2d.text.FlowPage; import org.eclipse.draw2d.text.TextFlow; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; public class BidiBlockExample { @@ -32,7 +33,7 @@ public static void main(String[] args) { // The backwards figure canvas for bidi protected FigureCanvas cf; - protected String s = "\u0634\u0635\u062c\u062d \u0630\u0628\u063a and some english text."; + protected String s = "\u0634\u0635\u062c\u062d \u0630\u0628\u063a and some english text."; //$NON-NLS-1$ protected IFigure createContents() { FlowPage page = new FlowPage(); diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/MultiLineLabelExample.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/MultiLineLabelExample.java index 413539679..56ef813e6 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/MultiLineLabelExample.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/MultiLineLabelExample.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.draw2d.examples.text; -import org.eclipse.draw2d.widgets.MultiLineLabel; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -18,6 +17,8 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import org.eclipse.draw2d.widgets.MultiLineLabel; + /** * This example shows the MultiLineLabel widget. MutliLineLabel is a widget for * displaying text that wraps, but *only* shows scrollbars when necessary. For diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/TextFlowExample.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/TextFlowExample.java index e7d1d8dea..7ce3b06e4 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/TextFlowExample.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/text/TextFlowExample.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.draw2d.examples.text; +import org.eclipse.swt.graphics.Font; + import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.FigureCanvas; import org.eclipse.draw2d.IFigure; @@ -20,7 +22,6 @@ import org.eclipse.draw2d.text.InlineFlow; import org.eclipse.draw2d.text.SimpleTextLayout; import org.eclipse.draw2d.text.TextFlow; -import org.eclipse.swt.graphics.Font; /** * This example shows the basic ways that the draw2d.text figures can be used. @@ -33,7 +34,8 @@ public class TextFlowExample extends AbstractExample { static protected IFigure createAlignmentParagraph() { BlockFlow block = new BlockFlow(); block.setHorizontalAligment(PositionConstants.RIGHT); - block.add(new TextFlow("An inline flow figure's aligment is determined by the block flow in which it resides. This block is aligned using ")); //$NON-NLS-1$ + block.add(new TextFlow( + "An inline flow figure's aligment is determined by the block flow in which it resides. This block is aligned using ")); //$NON-NLS-1$ TextFlow text = new TextFlow("PositionConstants.RIGHT"); //$NON-NLS-1$ text.setFont(COURIER); block.add(text); @@ -79,12 +81,12 @@ static protected IFigure createNestedInlineParagraph() { BlockFlow blockFlow = new BlockFlow(); TextFlow text; blockFlow.add(new TextFlow( - "A paragraph can contain multiple children, including" + " nested structure using InlineFlows. ")); + "A paragraph can contain multiple children, including" + " nested structure using InlineFlows. ")); //$NON-NLS-1$ //$NON-NLS-2$ InlineFlow inline = new InlineFlow(); inline.setForegroundColor(ColorConstants.darkBlue); - inline.add(new TextFlow( - "This TextFlow is inside an InlineFlow with a blue " + "foreground color. Children can have ")); + inline.add(new TextFlow( // $NON-NLS-1$ + "This TextFlow is inside an InlineFlow with a blue " + "foreground color. Children can have ")); //$NON-NLS-1$ //$NON-NLS-2$ text = new TextFlow("Bold "); //$NON-NLS-1$ text.setFont(BOLD); inline.add(text); @@ -110,7 +112,7 @@ static protected IFigure createParagraph() { The contents of this paragraph were created using a TextFlow figure\s\ in its default layout, which breaks at whitespace.\s\ a block of text that doesn't wrap can be created by using the\s\ - SimpleTextLayout on a TextFlow"""); + SimpleTextLayout on a TextFlow"""); // $NON-NLS-1$ //$NON-NLS-1$ blockFlow.add(contents); return blockFlow; @@ -151,7 +153,7 @@ public static void main(String[] args) { @Override protected void setFigureCanvas(FigureCanvas canvas) { super.setFigureCanvas(canvas); - // canvas.setVerticalScrollBarVisibility(canvas.ALWAYS); + // canvas.setVerticalScrollBarVisibility(canvas.ALWAYS); canvas.getViewport().setContentsTracksWidth(true); } diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/Animation.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/Animation.java index fd5b65d9f..f5858c633 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/Animation.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/Animation.java @@ -86,7 +86,7 @@ static boolean playbackState(IFigure container) { } List initial = initialStates.get(container); if (initial == null) { - System.out.println("Error playing back state"); + System.out.println("Error playing back state"); //$NON-NLS-1$ return false; } List target = finalStates.get(container); diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/TreeBranch.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/TreeBranch.java index 197fe4bdc..4bffb9864 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/TreeBranch.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/TreeBranch.java @@ -55,8 +55,8 @@ public void setBounds(Rectangle rect) { } bounds.width = rect.width; bounds.height = rect.height; - // if (resize) Layouts dont depend on size. - // invalidate(); + // if (resize) Layouts dont depend on size. + // invalidate(); if (resize || translate) { fireMoved(); repaint(); @@ -82,10 +82,10 @@ public List getChildren() { * by "transparent". If a layer is not used, then overlapping branches will * cause hit-test problems. */ - private AnimatingLayer contents = new AnimatingLayer(); + private final AnimatingLayer contents = new AnimatingLayer(); boolean expanded = true; - private IFigure node; + private final IFigure node; private int style; public TreeBranch(IFigure title) { @@ -257,9 +257,6 @@ public int getStyle() { return style; } - /** - * @return - */ public boolean isExpanded() { return expanded; } @@ -270,11 +267,10 @@ public boolean isExpanded() { @Override protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); - if (isExpanded()) - { + if (isExpanded()) { getBranchLayout().paintLines(graphics); - // if (getDepth() == 2) - // graphics.drawRectangle(getBounds().getResized(-1, -1)); + // if (getDepth() == 2) + // graphics.drawRectangle(getBounds().getResized(-1, -1)); } } diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/TreeRoot.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/TreeRoot.java index 23e29fa64..52d5dab46 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/TreeRoot.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/tree/TreeRoot.java @@ -21,7 +21,7 @@ public class TreeRoot extends TreeBranch { private int major = 10; private int minor = 10; - private Transposer transposer = new Transposer(); + private final Transposer transposer = new Transposer(); private boolean compression; /** @@ -43,9 +43,6 @@ public int getMajorSpacing() { return major; } - /** - * @return - */ public int getMinorSpacing() { return minor; } diff --git a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/uml/UMLClassDiagram.java b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/uml/UMLClassDiagram.java index cb3cfb289..aa04be85e 100644 --- a/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/uml/UMLClassDiagram.java +++ b/org.eclipse.draw2d.examples/src/org/eclipse/draw2d/examples/uml/UMLClassDiagram.java @@ -10,6 +10,10 @@ *******************************************************************************/ package org.eclipse.draw2d.examples.uml; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + import org.eclipse.draw2d.ChopboxAnchor; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.ConnectionEndpointLocator; @@ -24,9 +28,6 @@ import org.eclipse.draw2d.XYLayout; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; public class UMLClassDiagram { @@ -56,12 +57,12 @@ public static void main(String[] args) { assoc.setTargetDecoration(containment); diagram.add(assoc); - Label ref = new Label("end1"); + Label ref = new Label("end1"); //$NON-NLS-1$ ConnectionEndpointLocator locator = new ConnectionEndpointLocator(assoc, false); locator.setUDistance(8); assoc.add(ref, locator); - Label connLabel = new Label("connection"); + Label connLabel = new Label("connection"); //$NON-NLS-1$ connLabel.setBorder(new LineBorder()); connLabel.setOpaque(true); connLabel.setBackgroundColor(ColorConstants.tooltipBackground);