2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - DIGITEO - Bruno JOFRET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 package org.scilab.modules.graphic_objects;
15 import org.scilab.modules.graphic_objects.console.Console;
16 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
17 import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
18 import org.scilab.modules.graphic_objects.graphicView.ScilabView;
19 import org.scilab.modules.graphic_objects.utils.MenuBarBuilder;
22 * This is a static class to access all controller capabilities
23 * from C/C++ code through JNI
24 * See SCI/modules/graphic_objects/src/jni/graphic_objects.giws.xml for other details.
26 public final class CallGraphicController {
28 public static void setGraphicObjectRelationship(String parentId, String childId) {
29 GraphicController.getController().setGraphicObjectRelationship(parentId, childId);
32 public static void removeRelationShipAndDelete(String parentId) {
33 GraphicController.getController().removeRelationShipAndDelete(parentId);
36 public static String cloneGraphicObject(String id) {
37 return GraphicController.getController().cloneObject(id);
40 public static String askGraphicObject(int typeName) {
41 return GraphicController.getController().askObject(GraphicObject.getTypeFromName(typeName));
44 public static void deleteGraphicObject(String id) {
45 GraphicController.getController().deleteObject(id);
48 private static boolean setGraphicObjectProperty(String id, int propertyName, Object value) {
49 return GraphicController.getController().setProperty(id, propertyName, value);
52 private static Object getGraphicObjectProperty(String id, int propertyName) {
53 return GraphicController.getController().getProperty(id, propertyName);
56 public static boolean setGraphicObjectProperty(String id, int propertyName, String value) {
57 return setGraphicObjectProperty(id, propertyName, (Object) value);
60 public static boolean setGraphicObjectProperty(String id, int propertyName, String[] value) {
61 return setGraphicObjectProperty(id, propertyName, (Object) value);
64 public static boolean setGraphicObjectProperty(String id, int propertyName, double value) {
65 return setGraphicObjectProperty(id, propertyName, (Object) new Double(value));
68 public static boolean setGraphicObjectProperty(String id, int propertyName, double[] value) {
69 Double[] array = new Double[value.length];
71 for (int i = 0; i < value.length; i++) {
75 return setGraphicObjectProperty(id, propertyName, (Object) array);
79 public static boolean setGraphicObjectProperty(String id, int propertyName, int value) {
80 return setGraphicObjectProperty(id, propertyName, (Object) new Integer(value));
83 public static boolean setGraphicObjectProperty(String id, int propertyName, int[] value) {
84 Integer[] array = new Integer[value.length];
86 for (int i = 0; i < value.length; i++) {
90 return setGraphicObjectProperty(id, propertyName, (Object) array);
93 public static boolean setGraphicObjectProperty(String id, int propertyName, boolean value) {
94 return setGraphicObjectProperty(id, propertyName, (Object) new Boolean(value));
97 public static boolean setGraphicObjectProperty(String id, int propertyName, boolean[] value) {
98 Boolean[] array = new Boolean[value.length];
100 for (int i = 0; i < value.length; i++) {
104 return setGraphicObjectProperty(id, propertyName, (Object) array);
107 public static String getGraphicObjectPropertyAsString(String id, int propertyName) {
108 return (String) getGraphicObjectProperty(id, propertyName);
111 public static String[] getGraphicObjectPropertyAsStringVector(String id, int propertyName) {
112 return (String[]) getGraphicObjectProperty(id, propertyName);
115 public static double getGraphicObjectPropertyAsDouble(String id, int propertyName) {
116 return (Double) getGraphicObjectProperty(id, propertyName);
119 public static double[] getGraphicObjectPropertyAsDoubleVector(String id, int propertyName) {
120 Double[] tmp = (Double[]) getGraphicObjectProperty(id, propertyName);
126 double[] result = new double[tmp.length];
128 for (int i = 0; i < result.length; i++) {
135 public static int getGraphicObjectPropertyAsInteger(String id, int propertyName) {
136 return (Integer) getGraphicObjectProperty(id, propertyName);
139 public static int[] getGraphicObjectPropertyAsIntegerVector(String id, int propertyName) {
140 Integer[] tmp = (Integer[]) getGraphicObjectProperty(id, propertyName);
146 int[] result = new int[tmp.length];
148 for (int i = 0; i < result.length; i++) {
155 public static int getGraphicObjectPropertyAsBoolean(String id, int propertyName) {
158 Boolean tmpValue = (Boolean) getGraphicObjectProperty(id, propertyName);
160 result = Boolean.TRUE.equals(tmpValue) ? 1 : 0;
165 public static int[] getGraphicObjectPropertyAsBooleanVector(String id, int propertyName) {
166 Boolean[] tmp = (Boolean[]) getGraphicObjectProperty(id, propertyName);
172 int[] result = new int[tmp.length];
174 for (int i = 0; i < result.length; i++) {
175 result[i] = tmp[i] ? 1 : 0;
181 public static void registerScilabView() {
182 GraphicController.getController().register(ScilabView.getScilabView());
185 public static void unregisterScilabView() {
186 GraphicController.getController().unregister(ScilabView.getScilabView());
189 public static String getConsoleIdentifier() {
190 return Console.getConsole().getIdentifier();
193 public static void buildFigureMenuBar(String figureId) {
194 MenuBarBuilder.buildFigureMenuBar(figureId);