2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - Han DONG
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.1-en.txt
13 package org.scilab.modules.gui.uitable;
15 import java.awt.Color;
18 import org.scilab.modules.gui.bridge.ScilabBridge;
19 import org.scilab.modules.gui.events.callback.CommonCallBack;
20 import org.scilab.modules.gui.utils.Position;
21 import org.scilab.modules.gui.utils.Size;
22 import org.scilab.modules.gui.widget.ScilabWidget;
25 * Swing implementation for Scilab UiTable in GUIs
28 public class ScilabUiTable extends ScilabWidget implements UiTable {
30 private SimpleUiTable component;
35 protected ScilabUiTable() {
36 component = ScilabBridge.createUiTable();
40 * Creates a Scilab UiTable object
41 * @return the created UiTable
43 public static UiTable createUiTable() {
44 return new ScilabUiTable();
48 * Gets this Bridge component object
49 * @return this Bridge component object
51 public SimpleUiTable getAsSimpleUiTable() {
56 * Sets the text of a UiTable
57 * @param newText the text to set to the UiTable
59 public void setText(String newText) {
60 ScilabBridge.setText(this, newText);
63 public void setEmptyText() {
68 * Gets the text of a UiTable
69 * @return text of the UiTable
71 public String getText() {
72 return ScilabBridge.getText(this);
79 ScilabBridge.draw(this);
83 * Sets the dimensions (width and height) of a swing Scilab element
84 * @param newSize the dimensions to set to the element
85 * @see org.scilab.modules.gui.uielement.UIElement#setDims(org.scilab.modules.gui.utils.Size)
87 public void setDims(Size newSize) {
88 ScilabBridge.setDims(this, newSize);
92 * Gets the dimensions (width and height) of a swing Scilab element
93 * @return the dimensions (width and height) of the element
94 * @see org.scilab.modules.gui.uielement.UIElement#getDims(org.scilab.modules.gui.utils.Size)
96 public Size getDims() {
97 return ScilabBridge.getDims(this);
101 * Gets the position (X-coordinate and Y-coordinate) of a Scilab element
102 * @return the position of the element
103 * @see org.scilab.modules.gui.uielement.UIElement#getPosition()
105 public Position getPosition() {
106 return ScilabBridge.getPosition(this);
110 * Sets the position (X-coordinate and Y-coordinate) of a Scilab element
111 * @param newPosition the position we want to set to the element
112 * @see org.scilab.modules.gui.uielement.UIElement#setPosition(org.scilab.modules.gui.utils.Position)
114 public void setPosition(Position newPosition) {
115 ScilabBridge.setPosition(this, newPosition);
119 * Gets the visibility status of an UIElement
120 * @return the visibility status of the UIElement (true if the UIElement is visible, false if not)
122 public boolean isVisible() {
123 return ScilabBridge.isVisible(this);
127 * Sets the visibility status of a Menu
128 * @param newVisibleState the visibility status we want to set for the UIElement
129 * (true if the UIElement is visible, false if not)
131 public void setVisible(boolean newVisibleState) {
132 ScilabBridge.setVisible(this, newVisibleState);
136 * To get the Background color of the element.
137 * @return color the Color
139 public Color getBackground() {
140 return ScilabBridge.getBackground(this);
144 * To get the Font of the element.
145 * @return font the Font
147 public Font getFont() {
148 return ScilabBridge.getFont(this);
152 * To get the Foreground color of the element.
153 * @return color the Color
155 public Color getForeground() {
156 return ScilabBridge.getForeground(this);
160 * To set the Background color of the element.
161 * @param color the Color
163 public void setBackground(Color color) {
164 ScilabBridge.setBackground(this, color);
168 * To set the Font of the element.
169 * @param font the Font
171 public void setFont(Font font) {
172 ScilabBridge.setFont(this, font);
176 * To set the Foreground color of the element.
177 * @param color the Color
179 public void setForeground(Color color) {
180 ScilabBridge.setForeground(this, color);
184 * Add a callback to the UiTable
185 * @param callback the CallBack to set.
187 public void setCallback(CommonCallBack callback) {
188 ScilabBridge.setCallback(this, callback);
192 * Set if the UiTable is enabled or not
193 * @param status true if the UiTable is enabled
195 public void setEnabled(boolean status) {
196 ScilabBridge.setEnabled(this, status);
200 * Gets the enable status of a UiTable
201 * @return the enable status of the UiTable (true if the UiTable is enabled, false if not)
203 public boolean isEnabled() {
204 return ScilabBridge.isEnabled(this);
208 * Set the horizontal alignment for the UiTable text
209 * @param alignment the value for the alignment (See ScilabAlignment.java)
211 public void setHorizontalAlignment(String alignment) {
212 ScilabBridge.setHorizontalAlignment(this, alignment);
216 * Set the vertical alignment for the UiTable text
217 * @param alignment the value for the alignment (See ScilabAlignment.java)
219 public void setVerticalAlignment(String alignment) {
220 ScilabBridge.setVerticalAlignment(this, alignment);
224 * Set the Relief of the UiTable
225 * @param reliefType the type of the relief to set (See ScilabRelief.java)
227 public void setRelief(String reliefType) {
228 ScilabBridge.setRelief(this, reliefType);
234 public void destroy() {
235 ScilabBridge.destroy(this);
239 * Give the focus to the UiTable
241 public void requestFocus() {
242 ScilabBridge.requestFocus(this);
246 * Sets the column names for uitable
247 * @param text the String that contains column names delimited by "|"
249 public void setColnames(String text) {
250 ScilabBridge.setColnames(this, text);
254 * Sets the column names for uitable
255 * @param text the String that contains column names delimited by "|"
257 public void setColumnNames(String[] text) {
258 //ScilabBridge.setColnames(this, text);
262 * Sets the row names for uitable
263 * @param text the String that contains row name delimited by a "|"
265 public void setRownames(String text) {
266 ScilabBridge.setRownames(this, text);
270 * Sets the row names for uitable
271 * @param text the String that contains row name delimited by a "|"
273 public void setRowNames(String[] text) {
274 //ScilabBridge.setRownames(this, text);
278 * Sets the data for uitable
279 * @param text the String that contains row data delimited by a '|'
280 * and column data delimited by " ". Example: 1.26 3.47 | a b | d e | a b
282 public void setData(String text) {
283 ScilabBridge.setData(this, text);
287 public void setToolTipText(String tooltipText) {
288 // TODO Auto-generated method stub
292 public void resetBackground() {
293 // TODO Auto-generated method stub
298 public void resetForeground() {
299 // TODO Auto-generated method stub