Skip to content

Commit

Permalink
prmr#422 Update StringViewer constructor to reflect new instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
yannsartori authored and louib committed Aug 15, 2021
1 parent 44b3fe3 commit b510d79
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 18 deletions.
8 changes: 6 additions & 2 deletions src/ca/mcgill/cs/jetuml/viewers/edges/CallEdgeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*******************************************************************************/
package ca.mcgill.cs.jetuml.viewers.edges;

import static java.util.EnumSet.of;

import java.util.ArrayList;

import ca.mcgill.cs.jetuml.diagram.Edge;
Expand Down Expand Up @@ -53,8 +55,10 @@
*/
public final class CallEdgeViewer extends AbstractEdgeViewer
{
private static final StringViewer CENTERED_STRING_VIEWER = new StringViewer(StringViewer.Align.CENTER, false, false);
private static final StringViewer LEFT_JUSTIFIED_STRING_VIEWER = new StringViewer(StringViewer.Align.LEFT, false, false);
private static final StringViewer CENTERED_STRING_VIEWER = StringViewer.get(StringViewer.VerticalAlign.CENTER,
StringViewer.HorizontalAlign.CENTER, of(StringViewer.TextDecorations.PADDED));
private static final StringViewer LEFT_JUSTIFIED_STRING_VIEWER = StringViewer.get(StringViewer.VerticalAlign.TOP,
StringViewer.HorizontalAlign.LEFT, of(StringViewer.TextDecorations.PADDED));

private static final int SHIFT = -10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*******************************************************************************/
package ca.mcgill.cs.jetuml.viewers.edges;

import static java.util.EnumSet.of;

import java.util.function.Function;

import ca.mcgill.cs.jetuml.diagram.Edge;
Expand All @@ -36,7 +38,8 @@
*/
public class LabeledStraightEdgeViewer extends StraightEdgeViewer
{
private static final StringViewer STRING_VIEWER = new StringViewer(StringViewer.Align.CENTER, false, false);
private static final StringViewer STRING_VIEWER = StringViewer.get(StringViewer.VerticalAlign.CENTER,
StringViewer.HorizontalAlign.CENTER, of(StringViewer.TextDecorations.PADDED));
private static final int SHIFT = -10;

private final Function<Edge, String> aLabelExtractor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*******************************************************************************/
package ca.mcgill.cs.jetuml.viewers.edges;

import static java.util.EnumSet.of;

import ca.mcgill.cs.jetuml.diagram.Edge;
import ca.mcgill.cs.jetuml.diagram.edges.UseCaseDependencyEdge;
import ca.mcgill.cs.jetuml.geom.Rectangle;
Expand Down Expand Up @@ -48,8 +50,8 @@ public Canvas createIcon(Edge pEdge)
Canvas canvas = super.createIcon(pEdge);
final float scale = 0.75f;
canvas.getGraphicsContext2D().scale(scale, scale);
new StringViewer(StringViewer.Align.CENTER, false, false)
.draw(getIconTag(pEdge), canvas.getGraphicsContext2D(), new Rectangle(1, BUTTON_SIZE, 1, 1));
StringViewer.get(StringViewer.VerticalAlign.CENTER, StringViewer.HorizontalAlign.CENTER, of(StringViewer.TextDecorations.PADDED))
.draw(getIconTag(pEdge), canvas.getGraphicsContext2D(), new Rectangle(1, BUTTON_SIZE, 1, 1));
return canvas;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package ca.mcgill.cs.jetuml.viewers.nodes;

import static ca.mcgill.cs.jetuml.geom.GeomUtils.max;
import static java.util.EnumSet.of;

import ca.mcgill.cs.jetuml.diagram.Node;
import ca.mcgill.cs.jetuml.diagram.nodes.AbstractPackageNode;
Expand All @@ -43,7 +44,8 @@ public abstract class AbstractPackageNodeViewer extends AbstractNodeViewer
protected static final int DEFAULT_BOTTOM_HEIGHT = 60;
protected static final int DEFAULT_TOP_WIDTH = 60;
protected static final int NAME_GAP = 3;
private static final StringViewer NAME_VIEWER = new StringViewer(StringViewer.Align.LEFT, false, false);
private static final StringViewer NAME_VIEWER = StringViewer.get(StringViewer.VerticalAlign.TOP,
StringViewer.HorizontalAlign.LEFT, of(StringViewer.TextDecorations.PADDED));

@Override
public void draw(Node pNode, GraphicsContext pGraphics)
Expand Down
5 changes: 4 additions & 1 deletion src/ca/mcgill/cs/jetuml/viewers/nodes/ActorNodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*******************************************************************************/
package ca.mcgill.cs.jetuml.viewers.nodes;

import static java.util.EnumSet.of;

import ca.mcgill.cs.jetuml.diagram.Node;
import ca.mcgill.cs.jetuml.diagram.nodes.ActorNode;
import ca.mcgill.cs.jetuml.geom.Dimension;
Expand All @@ -38,7 +40,8 @@
*/
public final class ActorNodeViewer extends AbstractNodeViewer
{
private static final StringViewer NAME_VIEWER = new StringViewer(StringViewer.Align.CENTER, false, false);
private static final StringViewer NAME_VIEWER = StringViewer.get(StringViewer.VerticalAlign.CENTER,
StringViewer.HorizontalAlign.CENTER, of(StringViewer.TextDecorations.PADDED));

private static final int PADDING = 4;
private static final int HEAD_SIZE = 16;
Expand Down
11 changes: 8 additions & 3 deletions src/ca/mcgill/cs/jetuml/viewers/nodes/FieldNodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*******************************************************************************/
package ca.mcgill.cs.jetuml.viewers.nodes;

import static java.util.EnumSet.of;

import ca.mcgill.cs.jetuml.diagram.Node;
import ca.mcgill.cs.jetuml.diagram.nodes.FieldNode;
import ca.mcgill.cs.jetuml.diagram.nodes.ObjectNode;
Expand All @@ -42,9 +44,12 @@ public final class FieldNodeViewer extends AbstractNodeViewer
private static final int DEFAULT_WIDTH = 60;
private static final int DEFAULT_HEIGHT = 20;
private static final int XGAP = 5;
private static final StringViewer VALUE_VIEWER = new StringViewer(StringViewer.Align.LEFT, false, false);
private static final StringViewer NAME_VIEWER = new StringViewer(StringViewer.Align.LEFT, false, false);
private static final StringViewer EQUALS_VIEWER = new StringViewer(StringViewer.Align.LEFT, false, false);
private static final StringViewer VALUE_VIEWER = StringViewer.get(StringViewer.VerticalAlign.TOP,
StringViewer.HorizontalAlign.LEFT, of(StringViewer.TextDecorations.PADDED));
private static final StringViewer NAME_VIEWER = StringViewer.get(StringViewer.VerticalAlign.TOP,
StringViewer.HorizontalAlign.LEFT, of(StringViewer.TextDecorations.PADDED));
private static final StringViewer EQUALS_VIEWER = StringViewer.get(StringViewer.VerticalAlign.TOP,
StringViewer.HorizontalAlign.LEFT, of(StringViewer.TextDecorations.PADDED));
private static final int MID_OFFSET = EQUALS_VIEWER.getDimension(EQUALS).width() / 2;
private static final ObjectNodeViewer OBJECT_NODE_VIEWER = new ObjectNodeViewer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package ca.mcgill.cs.jetuml.viewers.nodes;

import static ca.mcgill.cs.jetuml.geom.GeomUtils.max;
import static java.util.EnumSet.of;

import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -49,7 +50,8 @@ public final class ImplicitParameterNodeViewer extends AbstractNodeViewer
private static final int TAIL_HEIGHT = 20; // Piece of the life line below the last call node
private static final int TOP_HEIGHT = 60;
private static final int Y_GAP_SMALL = 20;
private static final StringViewer NAME_VIEWER = new StringViewer(StringViewer.Align.CENTER, false, true);
private static final StringViewer NAME_VIEWER = StringViewer.get(StringViewer.VerticalAlign.CENTER,
StringViewer.HorizontalAlign.CENTER, of(StringViewer.TextDecorations.UNDERLINED, StringViewer.TextDecorations.PADDED));
private static final CallNodeViewer CALL_NODE_VIEWER = new CallNodeViewer();

@Override
Expand Down
5 changes: 4 additions & 1 deletion src/ca/mcgill/cs/jetuml/viewers/nodes/NoteNodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*******************************************************************************/
package ca.mcgill.cs.jetuml.viewers.nodes;

import static java.util.EnumSet.of;

import ca.mcgill.cs.jetuml.diagram.Node;
import ca.mcgill.cs.jetuml.diagram.nodes.NoteNode;
import ca.mcgill.cs.jetuml.geom.Dimension;
Expand All @@ -41,7 +43,8 @@ public final class NoteNodeViewer extends AbstractNodeViewer
private static final int DEFAULT_HEIGHT = 40;
private static final int FOLD_LENGTH = 8;
private static final Color NOTE_COLOR = Color.color(0.9f, 0.9f, 0.6f); // Pale yellow
private static final StringViewer NOTE_VIEWER = new StringViewer(StringViewer.Align.LEFT, false, false);
private static final StringViewer NOTE_VIEWER = StringViewer.get(StringViewer.VerticalAlign.TOP,
StringViewer.HorizontalAlign.LEFT, of(StringViewer.TextDecorations.PADDED));

@Override
public void draw(Node pNode, GraphicsContext pGraphics)
Expand Down
5 changes: 4 additions & 1 deletion src/ca/mcgill/cs/jetuml/viewers/nodes/ObjectNodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*******************************************************************************/
package ca.mcgill.cs.jetuml.viewers.nodes;

import static java.util.EnumSet.allOf;

import ca.mcgill.cs.jetuml.diagram.Node;
import ca.mcgill.cs.jetuml.diagram.nodes.FieldNode;
import ca.mcgill.cs.jetuml.diagram.nodes.ObjectNode;
Expand All @@ -41,7 +43,8 @@ public final class ObjectNodeViewer extends AbstractNodeViewer
private static final int TEXT_HORIZONTAL_MARGIN = 5;
private static final int XGAP = 5;
private static final int YGAP = 5;
private static final StringViewer NAME_VIEWER = new StringViewer(StringViewer.Align.CENTER, true, true);
private static final StringViewer NAME_VIEWER = StringViewer.get(StringViewer.VerticalAlign.CENTER,
StringViewer.HorizontalAlign.CENTER, allOf(StringViewer.TextDecorations.class));
private static final FieldNodeViewer FIELD_NODE_VIEWER = new FieldNodeViewer();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package ca.mcgill.cs.jetuml.viewers.nodes;

import static ca.mcgill.cs.jetuml.geom.GeomUtils.max;
import static java.util.EnumSet.of;

import ca.mcgill.cs.jetuml.diagram.Node;
import ca.mcgill.cs.jetuml.diagram.nodes.AbstractPackageNode;
Expand All @@ -36,7 +37,8 @@
*/
public final class PackageDescriptionNodeViewer extends AbstractPackageNodeViewer
{
private static final StringViewer CONTENTS_VIEWER = new StringViewer(StringViewer.Align.CENTER, false, false);
private static final StringViewer CONTENTS_VIEWER = StringViewer.get(StringViewer.VerticalAlign.CENTER,
StringViewer.HorizontalAlign.CENTER, of(StringViewer.TextDecorations.PADDED));

@Override
public void draw(Node pNode, GraphicsContext pGraphics)
Expand Down
5 changes: 4 additions & 1 deletion src/ca/mcgill/cs/jetuml/viewers/nodes/StateNodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*******************************************************************************/
package ca.mcgill.cs.jetuml.viewers.nodes;

import static java.util.EnumSet.of;

import ca.mcgill.cs.jetuml.diagram.Node;
import ca.mcgill.cs.jetuml.diagram.nodes.StateNode;
import ca.mcgill.cs.jetuml.geom.Dimension;
Expand All @@ -38,7 +40,8 @@ public final class StateNodeViewer extends AbstractNodeViewer
{
private static final int DEFAULT_WIDTH = 80;
private static final int DEFAULT_HEIGHT = 60;
private static final StringViewer NAME_VIEWER = new StringViewer(StringViewer.Align.CENTER, false, false);
private static final StringViewer NAME_VIEWER = StringViewer.get(StringViewer.VerticalAlign.CENTER,
StringViewer.HorizontalAlign.CENTER, of(StringViewer.TextDecorations.PADDED));

@Override
public void draw(Node pNode, GraphicsContext pGraphics)
Expand Down
7 changes: 5 additions & 2 deletions src/ca/mcgill/cs/jetuml/viewers/nodes/TypeNodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package ca.mcgill.cs.jetuml.viewers.nodes;

import static ca.mcgill.cs.jetuml.geom.GeomUtils.max;
import static java.util.EnumSet.of;

import ca.mcgill.cs.jetuml.diagram.Node;
import ca.mcgill.cs.jetuml.diagram.nodes.TypeNode;
Expand All @@ -42,8 +43,10 @@ public class TypeNodeViewer extends AbstractNodeViewer
protected static final int DEFAULT_WIDTH = 100;
protected static final int DEFAULT_HEIGHT = 60;
protected static final int TOP_INCREMENT = 20;
private static final StringViewer NAME_VIEWER = new StringViewer(StringViewer.Align.CENTER, true, false);
private static final StringViewer STRING_VIEWER = new StringViewer(StringViewer.Align.LEFT, false, false);
private static final StringViewer NAME_VIEWER = StringViewer.get(StringViewer.VerticalAlign.CENTER,
StringViewer.HorizontalAlign.CENTER, of(StringViewer.TextDecorations.BOLD, StringViewer.TextDecorations.PADDED));
private static final StringViewer STRING_VIEWER = StringViewer.get(StringViewer.VerticalAlign.TOP,
StringViewer.HorizontalAlign.LEFT, of(StringViewer.TextDecorations.PADDED));

@Override
public void draw(Node pNode, GraphicsContext pGraphics)
Expand Down
5 changes: 4 additions & 1 deletion src/ca/mcgill/cs/jetuml/viewers/nodes/UseCaseNodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*******************************************************************************/
package ca.mcgill.cs.jetuml.viewers.nodes;

import static java.util.EnumSet.of;

import ca.mcgill.cs.jetuml.diagram.Node;
import ca.mcgill.cs.jetuml.diagram.nodes.UseCaseNode;
import ca.mcgill.cs.jetuml.geom.Direction;
Expand All @@ -39,7 +41,8 @@ public final class UseCaseNodeViewer extends AbstractNodeViewer
private static final int DEFAULT_WIDTH = 110;
private static final int DEFAULT_HEIGHT = 40;
private static final int HORIZONTAL_NAME_PADDING = 30;
private static final StringViewer NAME_VIEWER = new StringViewer(StringViewer.Align.CENTER, false, false);
private static final StringViewer NAME_VIEWER = StringViewer.get(StringViewer.VerticalAlign.CENTER,
StringViewer.HorizontalAlign.CENTER, of(StringViewer.TextDecorations.PADDED));

@Override
public void draw(Node pNode, GraphicsContext pGraphics)
Expand Down

0 comments on commit b510d79

Please sign in to comment.