aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/constants
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2015-03-09 16:40:17 -0300
committerEduardo Pedroni <e.pedroni91@gmail.com>2015-03-09 16:40:17 -0300
commitff5248437491f1829c0168b271e85cb358516577 (patch)
tree1c41e92769d8186b2d6e05efe8bdb6d205b01156 /src/jcgp/gui/constants
parentdb2bc6e935ff1632d78ea8a03606b396944ef21e (diff)
Moved GUI to its own repositoryHEADmaster
Diffstat (limited to 'src/jcgp/gui/constants')
-rw-r--r--src/jcgp/gui/constants/Constants.java170
-rw-r--r--src/jcgp/gui/constants/Position.java103
2 files changed, 0 insertions, 273 deletions
diff --git a/src/jcgp/gui/constants/Constants.java b/src/jcgp/gui/constants/Constants.java
deleted file mode 100644
index 509d982..0000000
--- a/src/jcgp/gui/constants/Constants.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package jcgp.gui.constants;
-
-import javafx.scene.paint.Paint;
-
-/**
- * Holds the constants used in the GUI.
- *
- * @author Eduardo Pedroni
- *
- */
-public final class Constants {
-
- /**
- * Private constructor to prevent instantiation.
- */
- private Constants(){}
-
- /*---------------------------------------------------------------------------------------------------
- * Colour Strings
- *-------------------------------------------------------------------------------------------------*/
- /**
- * A {@code String} containing the colour used for representing neutrality.
- */
- public static final String NEUTRAL_COLOUR = "#FFFFFF";
- /**
- * A {@code String} containing the hexadecimal colour used for representing a hard highlight.
- * A "hard" select, for instance, happens when an output path is locked on the chromosome pane.
- */
- public static final String HARD_HIGHLIGHT_COLOUR = "#5496FF";
- /**
- * A {@code String} containing the hexadecimal colour used for a medium highlight.
- * One example of such a selection is the colour applied to a node when it is hovered over.
- */
- public static final String MEDIUM_HIGHLIGHT_COLOUR = "#75BAFF";
- /**
- * A {@code String} containing the hexadecimal colour used for a soft highlight.
- * When hovering over a node, its connections are soft-selected.
- */
- public static final String SOFT_HIGHLIGHT_COLOUR = "#C7DFFF";
- /**
- * A {@code String} containing the hexadecimal colour used for representing a good selection.
- * Ideally a shade of green, used for instance when a manual connection is valid.
- */
- public static final String GOOD_SELECTION_COLOUR = "#38C25B";
- /**
- * A {@code String} containing the hexadecimal colour used for representing a neutral selection.
- * Ideally a shade of yellow, used for instance when a manual connection is already the current connection.
- */
- public static final String NEUTRAL_SELECTION_COLOUR = "#FFEF73";
- /**
- * A {@code String} containing the hexadecimal colour used for representing a bad selection.
- * Ideally a shade of red, use for instance when a manual connection is not valid.
- */
- public static final String BAD_SELECTION_COLOUR = "#FF5C5C";
- /**
- * A {@code String} containing the hexadecimal colour used for the gene sockets.
- */
- public static final String SOCKET_COLOUR = "#FFFFFF";
-
- /*---------------------------------------------------------------------------------------------------
- * Colour Paints
- *-------------------------------------------------------------------------------------------------*/
- /**
- * A {@code Paint} containing the colour used for representing neutrality.
- */
- public static final Paint NEUTRAL_PAINT = Paint.valueOf(NEUTRAL_COLOUR);
- /**
- * A {@code Paint} containing the colour used for representing a hard highlight.
- * A "hard" select, for instance, happens when an output path is locked on the chromosome pane.
- */
- public static final Paint HARD_HIGHLIGHT_PAINT = Paint.valueOf(HARD_HIGHLIGHT_COLOUR);
- /**
- * A {@code Paint} containing the colour used for a medium highlight.
- * One example of such a selection is the colour applied to a node when it is hovered over.
- */
- public static final Paint MEDIUM_HIGHLIGHT_PAINT = Paint.valueOf(MEDIUM_HIGHLIGHT_COLOUR);
- /**
- * A {@code Paint} containing the colour used for a soft highlight.
- * When hovering over a node, its connections are soft-selected.
- */
- public static final Paint SOFT_HIGHLIGHT_PAINT = Paint.valueOf(SOFT_HIGHLIGHT_COLOUR);
- /**
- * A {@code Paint} containing the colour used for representing a good selection.
- * Ideally a shade of green, used for instance when a manual connection is valid.
- */
- public static final Paint GOOD_SELECTION_PAINT = Paint.valueOf(GOOD_SELECTION_COLOUR);
- /**
- * A {@code Paint} containing the colour used for representing a neutral selection.
- * Ideally a shade of yellow, used for instance when a manual connection is already the current connection.
- */
- public static final Paint NEUTRAL_SELECTION_PAINT = Paint.valueOf(NEUTRAL_SELECTION_COLOUR);
- /**
- * A {@code Paint} containing the colour used for representing a bad selection.
- * Ideally a shade of red, use for instance when a manual connection is not valid.
- */
- public static final Paint BAD_SELECTION_PAINT = Paint.valueOf(BAD_SELECTION_COLOUR);
- /**
- * A {@code Paint} containing the colour used for the gene sockets.
- */
- public static final Paint SOCKET_PAINT = Paint.valueOf(SOCKET_COLOUR);
-
- /*---------------------------------------------------------------------------------------------------
- * Sizes and distances
- *-------------------------------------------------------------------------------------------------*/
- /**
- * The width or height of the area that can be clicked on
- * to drag-resize a pane.
- */
- public static final double RESIZE_MARGIN = 5.0;
- /**
- * The minimum width of the settings pane, to prevent it
- * from being resized beyond visibility.
- */
- public static final double SETTINGS_MIN_WIDTH = 200;
- /**
- * The minimum width of the console pane, to prevent it
- * from being resized beyond visibility.
- */
- public static final double CONSOLE_MIN_HEIGHT = 100;
- /**
- * Radius used for the representation of nodes in the grid.
- */
- public static final double NODE_RADIUS = 35;
- /**
- * Spacing between each node.
- */
- public static final double SPACING = 15;
- /**
- * The margin between the genes and the edge of the chromosome pane.
- */
- public static final double CHROMOSOME_PANE_MARGIN = 10;
- /**
- * The angle across which the node's sockets are evenly distributed.
- */
- public static final double THETA = Math.PI / 1.4;
- /**
- * The radius of the connection sockets, calculated as a function of NODE_RADIUS.
- */
- public static final double SOCKET_RADIUS = Math.sqrt(NODE_RADIUS) / 1.8;
- /**
- * Size of the text in each node.
- */
- public static final double NODE_TEXT = NODE_RADIUS / 2.5;
-
- /*---------------------------------------------------------------------------------------------------
- * CSS Styles
- * TODO extract to stylesheet?
- *-------------------------------------------------------------------------------------------------*/
- /**
- * The basic style of text boxes used in parameters.
- */
- public static final String BASE_TEXT_STYLE = "-fx-border-color: #C9C9C9; -fx-border-radius: 2; -fx-padding: 0; ";
- /**
- * The basic style of check boxes used in parameters.
- */
- public static final String BASE_CHECKBOX_STYLE = "-fx-padding: 0; ";
- /**
- * The style applied to invalid parameters, using BAD_SELECTION_COLOUR.
- */
- public static final String INVALID_PARAMETER_STYLE = "-fx-background-color: " + BAD_SELECTION_COLOUR;
- /**
- * The style applied to neutral parameters, using NEUTRAL_SELECTION_COLOUR.
- */
- public static final String WARNING_PARAMETER_STYLE = "-fx-background-color: " + NEUTRAL_SELECTION_COLOUR;
- /**
- * The style applied to valid parameters, using NEUTRAL_COLOUR.
- */
- public static final String VALID_PARAMETER_STYLE = "-fx-background-color: " + NEUTRAL_COLOUR;
-
-}
diff --git a/src/jcgp/gui/constants/Position.java b/src/jcgp/gui/constants/Position.java
deleted file mode 100644
index 6d4e02b..0000000
--- a/src/jcgp/gui/constants/Position.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package jcgp.gui.constants;
-
-import javafx.scene.shape.Circle;
-import javafx.scene.shape.Line;
-import jcgp.gui.GUI;
-import jcgp.gui.population.GUIGene;
-import jcgp.gui.population.GUIInput;
-import jcgp.gui.population.GUINode;
-import jcgp.gui.population.GUIOutput;
-
-/**
- * Abstracts the task of positioning GUI components.
- * <br>
- * Do not instantiate this class; instead, use the {@code public static} methods provided.
- *
- * @author Eduardo Pedroni
- *
- */
-public final class Position {
-
- /**
- * Private constructor to prevent instantiation.
- */
- private Position() {}
-
- /**
- * Sets the X and Y layouts of the specified input to the appropriate values, according to its index.
- *
- * @param input the {@code GUIInput} instance to relocate.
- */
- public static void place(GUIInput input) {
- // inputs are the first column, so we only worry about the margin and their index
- input.relocate(Constants.CHROMOSOME_PANE_MARGIN,
- input.getInput().getIndex() * (2 * Constants.NODE_RADIUS + Constants.SPACING) + Constants.CHROMOSOME_PANE_MARGIN);
- }
-
- /**
- * Sets the X and Y layouts of the specified node to the appropriate values, according to its row and column values.
- * This also connects the start of every line with its respective socket. Therefore, this method should be called at least
- * once when the {@code GUINode} is instantiated.
- *
- * @param node the {@code GUINode} instance to relocate.
- */
- public static void place(GUINode node) {
- // calculate x and y offsets, in relation to the layout origin
- double xOffset = (node.getNode().getColumn() + 1) * (2 * Constants.NODE_RADIUS + Constants.SPACING) + Constants.CHROMOSOME_PANE_MARGIN;
- double yOffset = node.getNode().getRow() * (2 * Constants.NODE_RADIUS + Constants.SPACING) + Constants.CHROMOSOME_PANE_MARGIN;
-
- // move node
- node.relocate(xOffset, yOffset);
-
- // use the offset and the socket positions to connect the lines
- for (int i = 0; i < GUI.resources.arity(); i++) {
- node.getLines()[i].setStartX(node.getSocket(i).getCenterX() + xOffset + Constants.NODE_RADIUS + Constants.SOCKET_RADIUS);
- node.getLines()[i].setStartY(node.getSocket(i).getCenterY() + yOffset + Constants.NODE_RADIUS);
- }
- }
-
- /**
- * Sets the X and Y layouts of the specified output to the appropriate values, according to its index.
- * This also connects the start of the output's single line to its single input socket.Therefore,
- * this method should be called at least once when the {@code GUIOutput} is instantiated.
- *
- * @param output the {@code GUIOutput} instance to relocate.
- */
- public static void place(GUIOutput output) {
- // the output's position is a function of the number of columns and its own index
- output.relocate(((GUI.resources.columns() + 1) * (2 * Constants.NODE_RADIUS + Constants.SPACING)) + Constants.CHROMOSOME_PANE_MARGIN,
- output.getOutput().getIndex() * (2 * Constants.NODE_RADIUS + Constants.SPACING) + Constants.CHROMOSOME_PANE_MARGIN);
- output.getLines()[0].setStartX(output.getLayoutX() - Constants.NODE_RADIUS);
- output.getLines()[0].setStartY(output.getLayoutY());
- }
-
- /**
- * Connects the end of a specified line to the specified gene.
- *
- * @param line the line to connect.
- * @param target the target gene to connect to.
- */
- public static void connect(Line line, GUIGene target) {
- // set line ends based on the layout position of the target
- line.setEndX(target.getLayoutX() + Constants.NODE_RADIUS);
- line.setEndY(target.getLayoutY());
- }
-
- /**
- * Relocates the given socket to the appropriate position given the
- * socket's index.
- *
- * @param index the socket index.
- * @param socket the {@code Circle} instance to relocate.
- */
- public static void placeSocket(int index, Circle socket) {
- // calculate the angle with respect to the x-axis
- double angle = (((index + 1) / ((double) (GUI.resources.arity() + 1))) * Constants.THETA) - (Constants.THETA / 2);
- // convert to cartesian form
- double xPos = -Math.cos(angle) * Constants.NODE_RADIUS;
- double yPos = Math.sin(angle) * Constants.NODE_RADIUS;
- // set centre
- socket.setCenterX(xPos);
- socket.setCenterY(yPos);
- }
-}