~ubuntu-branches/ubuntu/trusty/scilab/trusty

« back to all changes in this revision

Viewing changes to modules/xcos/src/java/org/scilab/modules/xcos/block/TextBlock.java

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-02 11:02:49 UTC
  • mfrom: (1.4.6)
  • Revision ID: package-import@ubuntu.com-20120802110249-0v5953emkp25geuz
Tags: 5.4.0-beta-2-1~exp1
* New upstream release
* Remove libscilab-java (remove upstream). Use libscilab2-java instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import org.scilab.modules.graph.utils.Font;
20
20
import org.scilab.modules.graph.utils.StyleMap;
21
21
import org.scilab.modules.gui.menu.Menu;
 
22
import org.scilab.modules.types.ScilabDouble;
22
23
import org.scilab.modules.types.ScilabString;
23
24
import org.scilab.modules.types.ScilabType;
24
25
import org.scilab.modules.xcos.block.actions.BlockParametersAction;
53
54
    }
54
55
 
55
56
    /**
56
 
     * @return the text
57
 
     */
58
 
    public String getText() {
59
 
        return ((ScilabString) getExprs()).getData()[0][0];
60
 
    }
61
 
 
62
 
    /**
63
57
     * @return the fontNumber
64
58
     */
65
59
    private Font getFont() {
66
 
        int number = Integer
67
 
                .parseInt(((ScilabString) getExprs()).getData()[1][0]);
 
60
        int number = Integer.parseInt(getLocalExprs().getData()[1][0]);
68
61
        return Font.getFont(number);
69
62
    }
70
63
 
72
65
     * @return the fontSize
73
66
     */
74
67
    private int getFontSize() {
75
 
        return Font.getSize(((ScilabString) getExprs()).getData()[2][0]);
 
68
        return Font.getSize(getLocalExprs().getData()[2][0]);
 
69
    }
 
70
 
 
71
    /**
 
72
     * Format exprs as a Scilab valid one
 
73
     */
 
74
    @Override
 
75
    public ScilabType getExprs() {
 
76
        final String[][] data = new String[][] { new String[] { getValue().toString(), "2", "1" } };
 
77
        return new ScilabString(data);
 
78
    }
 
79
 
 
80
    /**
 
81
     * Exprs accessor
 
82
     */
 
83
    private ScilabString getLocalExprs() {
 
84
        return (ScilabString) super.getExprs();
 
85
    }
 
86
 
 
87
    @Override
 
88
    public ScilabType getRealParameters() {
 
89
        return new ScilabString(getValue().toString());
 
90
    }
 
91
 
 
92
    @Override
 
93
    public ScilabType getIntegerParameters() {
 
94
        final double[][] data = new double[][] { new double[] { 2, 1 } };
 
95
        return new ScilabDouble(data);
76
96
    }
77
97
 
78
98
    /**
79
99
     * Apply style on setExprs
80
 
     * 
 
100
     *
81
101
     * @param exprs
82
102
     *            the expression to be parsed
83
103
     */
85
105
    public void setExprs(ScilabType exprs) {
86
106
        super.setExprs(exprs);
87
107
 
88
 
        StyleMap map = new StyleMap(getStyle());
 
108
        final StyleMap map = new StyleMap(getStyle());
89
109
        map.put(mxConstants.STYLE_FONTFAMILY, getFont().getName());
90
110
        map.put(mxConstants.STYLE_FONTSIZE, Integer.toString(getFontSize()));
91
 
 
92
111
        setStyle(map.toString());
 
112
 
 
113
        setValue(getLocalExprs().getData()[0][0]);
93
114
    }
94
115
 
95
116
    /**
96
117
     * Disabling BlockSettings action
97
 
     * 
 
118
     *
98
119
     * @param context
99
120
     *            the current context
100
121
     */
105
126
 
106
127
    /**
107
128
     * Disabling BlockSettings action
108
 
     * 
 
129
     *
109
130
     * @param modifiedBlock
110
131
     *            the updated block
111
132
     */
116
137
 
117
138
    /**
118
139
     * Customize menu
119
 
     * 
 
140
     *
120
141
     * @param menuList
121
142
     *            the menuList to work on
122
143
     */
123
144
    @Override
124
 
    protected void customizeMenu(
125
 
            Map<Class<? extends DefaultAction>, Menu> menuList) {
 
145
    protected void customizeMenu(Map < Class <? extends DefaultAction > , Menu > menuList) {
126
146
        menuList.get(BlockParametersAction.class).setEnabled(false);
127
147
        menuList.get(RegionToSuperblockAction.class).setEnabled(false);
128
148
    }