/** * Gets the position (X-coordinate and Y-coordinate) of a swing Scilab element * * @return the position of the element * @see org.scilab.modules.gui.uielement.UIElement#getPosition() */ public Position getPosition() { return PositionConverter.javaToScilab(getLocation(), getSize(), getParent()); }
/** * Sets the position (X-coordinate and Y-coordinate) of a swing Scilab element * * @param newPosition the position to set to the element * @see * org.scilab.modules.gui.uielement.UIElement#setPosition(org.scilab.modules.gui.utils.Position) */ public void setPosition(Position newPosition) { Position javaPosition = PositionConverter.scilabToJava(newPosition, getDims(), getParent()); setLocation(javaPosition.getX(), javaPosition.getY()); }
public void update(int property, Object value) { switch (property) { case __GO_VISIBLE__: setVisible((Boolean) value); break; case __GO_UI_TITLE_POSITION__: Integer pos = (Integer) value; switch (Uicontrol.TitlePositionType.intToEnum(pos)) { case BOTTOM: setTabPlacement(JTabbedPane.BOTTOM); break; case LEFT: setTabPlacement(JTabbedPane.LEFT); break; case RIGHT: setTabPlacement(JTabbedPane.RIGHT); break; case TOP: default: setTabPlacement(JTabbedPane.TOP); break; } break; case __GO_UI_TITLE_SCROLL__: if ((Boolean) value) { setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); } else { setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT); } break; case __GO_UI_FONTNAME__: case __GO_UI_FONTANGLE__: case __GO_UI_FONTSIZE__: case __GO_UI_FONTWEIGHT__: { for (int i = 0; i < getTabCount(); i++) { setTitleAt(i, null); } break; } case __GO_POSITION__: { Double[] positions = (Double[]) value; setSize(positions[2].intValue(), positions[3].intValue()); Position javaPosition = PositionConverter.scilabToJava( new Position(positions[0].intValue(), positions[1].intValue()), new Size(getSize().width, getSize().height), getParent()); setLocation(javaPosition.getX(), javaPosition.getY()); break; } case __GO_UI_VALUE__: { Double[] doubleValue = ((Double[]) value); if (doubleValue.length == 0) { return; } Integer val = doubleValue[0].intValue(); // if intValue[0] is out of bounds, do not update view but let "wrong" value in model if (val > 0 && val <= getTabCount()) { setSelectedIndex(val - 1); } break; } case __GO_UI_STRING__: { // set tab by his name String name = ((String[]) value)[0]; for (int i = 0; i < getTabCount(); i++) { JLabel current = (JLabel) getTabComponentAt(i); if (current != null && current.getText() != null && current.getText().equals(name)) { setSelectedIndex(i); break; } } break; } case __GO_CALLBACK__: { int cbType = (Integer) GraphicController.getController().getProperty(getId(), __GO_CALLBACKTYPE__); callback = CommonCallBack.createCallback((String) value, cbType, getId()); break; } case __GO_CALLBACKTYPE__: { String cbString = (String) GraphicController.getController().getProperty(getId(), __GO_CALLBACK__); if ((Integer) value == CallBack.UNTYPED) { // Disable callback callback = null; } else { callback = CommonCallBack.createCallback(cbString, (Integer) value, getId()); } break; } default: { SwingViewWidget.update(this, property, value); } } }