2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - DIGITEO - Clement David
4 * Copyright (C) 2011-2015 - Scilab Enterprises - Clement DAVID
5 * Copyright (C) 2015 - Marcos CARDINOT
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
11 * This file was originally licensed under the terms of the CeCILL v2.1,
12 * and continues to be available under such terms.
13 * For more information, see the COPYING file which you should have received
14 * along with this program.
18 package org.scilab.modules.xcos.utils;
20 import java.awt.Dimension;
22 import org.scilab.modules.graph.utils.ScilabGraphConstants;
25 * Contains all the constants used trough the source code.
27 public final class XcosConstants extends ScilabGraphConstants {
29 /** Define the default block height on the palette */
30 public static final double PALETTE_BLOCK_ICON_RATIO = 1.5;
32 /** Define the default block horizontal margin on the palette */
33 public static final int PALETTE_HMARGIN = 5;
34 /** Define the default block vertical margin on the palette */
35 public static final int PALETTE_VMARGIN = 5;
37 /** Define the maximum number of char that might be represented as style */
38 public static final int MAX_CHAR_IN_STYLE = 37;
40 /** Define the maximum number of blocks on the "Recently Used Blocks" palette */
41 public static final int MAX_RECENTLY_USED_BLOCKS = 12;
43 /** Define the history length */
44 public static final int HISTORY_LENGTH = 20;
46 /** Define the maximum number of hits to be displayed */
47 public static final int MAX_HITS = 150;
49 /** the size of the palette block **/
50 public enum PaletteBlockSize {
59 /** Extra large size **/
62 private static final Dimension DIM_TINY = new Dimension(50, 50);
63 private static final Dimension DIM_SMALL = new Dimension(75, 75);
64 private static final Dimension DIM_NORMAL = new Dimension(100, 100);
65 private static final Dimension DIM_LARGE = new Dimension(120, 120);
66 private static final Dimension DIM_XLARGE = new Dimension(140, 140);
71 public int getFontSize() {
89 * @return maximum icon height
91 public int getMaxIconHeight() {
92 // 65% of the frame height
93 return (int) (getBlockDimension().height * 0.65f);
97 * @return maximum icon width
99 public int getMaxIconWidth() {
100 // 65% of the frame width
101 return (int) (getBlockDimension().width * 0.65f);
105 * @return block dimension (width and height)
107 public Dimension getBlockDimension() {
126 * @return enum or null if there is no next
128 public PaletteBlockSize next() {
129 if (this.ordinal() < values().length - 1) {
130 return values()[ordinal() + 1];
136 * Get the previous size
137 * @return enum or null if there is no previous
139 public PaletteBlockSize previous() {
140 if (this.ordinal() > 0) {
141 return values()[ordinal() - 1];
149 * When a block changed
151 public static final String EVENT_BLOCK_UPDATED = "block";
152 /** Change event old name */
153 public static final String EVENT_CHANGE_OLD = "old";
154 /** Change event new name */
155 public static final String EVENT_CHANGE_NEW = "new";
157 /* SCI environment */
158 /** Path from SCI or SCIHOME to the Xcos configuration directory */
159 public static final String XCOS_ETC = "/modules/xcos/etc";
161 /** This class is a static singleton, thus it must not be instantiated */
162 private XcosConstants() {