001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.channel.markup.html.renderer;
032:
033: import java.util.*;
034:
035: import de.ug2t.channel.markup.generic.*;
036: import de.ug2t.kernel.*;
037:
038: public class HtmlMouseSliderRenderer extends
039: AMuGenericComponentRenderer {
040: public String pcmf_render(MuGenericComponent xWidget) {
041: KeStringTemplate l_main = null;
042: KeStringTemplate l_steps = null;
043: KeStringTemplate l_steps_min = null;
044: KeStringTemplate l_steps_max = null;
045: KeStringTemplate l_submit = null;
046: KeStringTemplate l_disabled = null;
047:
048: MuGenericSlider l_slider = (MuGenericSlider) xWidget;
049:
050: int l_stepcnt = l_slider.pcmf_getSteps();
051: int l_slWi = l_slider.pcmf_getSliderWidth() + 80;
052: int l_slHi = l_slider.pcmf_getSliderHeight();
053: int l_slMin = l_slider.pcmf_getMinimum();
054: int l_slMax = l_slider.pcmf_getMaximum();
055: double l_val = Double.parseDouble(l_slider.pcmf_getValue()
056: .toString());
057:
058: long l_sPos = Math.round((double) (l_slWi - 15)
059: / (double) (l_slMax - l_slMin) * l_val);
060: if (l_sPos > l_slWi - 15)
061: l_sPos = l_slWi - 15;
062:
063: if (l_slider.pcmf_getDirection() == MuGenericSlider.SLIDE_HORIZONTAL) {
064: l_main = l_slider.pcmf_getMarkupString("H_MAIN");
065: l_steps = l_slider.pcmf_getMarkupString("H_STEPS");
066: l_steps_min = l_slider.pcmf_getMarkupString("H_STEPS_MIN");
067: l_steps_max = l_slider.pcmf_getMarkupString("H_STEPS_MAX");
068: } else {
069: l_main = l_slider.pcmf_getMarkupString("V_MAIN");
070: l_steps = l_slider.pcmf_getMarkupString("V_STEPS");
071: l_steps_min = l_slider.pcmf_getMarkupString("V_STEPS_MIN");
072: l_steps_max = l_slider.pcmf_getMarkupString("V_STEPS_MAX");
073: }
074: l_submit = l_slider.pcmf_getMarkupString("SUBMIT");
075: l_disabled = l_slider.pcmf_getMarkupString("DISABLED");
076:
077: l_main = l_slider.pcmf_insertToolTip(l_main);
078: l_main = l_slider.pcmf_insertColorandFontandBorder(l_main);
079: l_main = l_slider.pcmf_insertPosition(l_main);
080: l_main = l_slider.pcmf_insertChannelandMenu(l_main);
081:
082: l_main.pcmf_beginTR();
083:
084: if (l_slider.pcmf_isSubmit())
085: l_main = KeTools.pcmf_stringSubst(l_main, "$SUBMIT",
086: l_submit);
087: else
088: l_main = KeTools.pcmf_stringSubst(l_main, "$SUBMIT", "");
089:
090: if (l_slider.pcmf_isDisabled())
091: l_main = KeTools.pcmf_stringSubst(l_main, "$DISABLED",
092: l_disabled);
093: else
094: l_main = KeTools.pcmf_stringSubst(l_main, "$DISABLED", "");
095:
096: l_main = KeTools.pcmf_stringSubst(l_main, "$OID", l_slider
097: .pcmf_getObjName());
098: l_main = KeTools.pcmf_stringSubst(l_main, "$NAME", l_slider
099: .pcmf_getObjName());
100: l_main = KeTools.pcmf_stringSubst(l_main, "$STEPCNT", Integer
101: .toString(l_stepcnt == 0 ? 1 : (l_slMax - l_slMin)
102: / l_stepcnt + 1));
103: l_main = KeTools.pcmf_stringSubst(l_main, "$SL_WIDTH", Integer
104: .toString(l_slWi));
105: l_main = KeTools.pcmf_stringSubst(l_main, "$SL_HEIGHT", Integer
106: .toString(l_slHi));
107: l_main = KeTools.pcmf_stringSubst(l_main, "$MIN", Integer
108: .toString(l_slMin));
109: l_main = KeTools.pcmf_stringSubst(l_main, "$MAX", Integer
110: .toString(l_slMax));
111: l_main = KeTools.pcmf_stringSubst(l_main, "$SL_SIZE", "15");
112: l_main = KeTools.pcmf_stringSubst(l_main, "$SPOS", Long
113: .toString(l_sPos));
114: l_main = KeTools.pcmf_stringSubst(l_main, "$SCOLOR", l_slider
115: .pcmf_getFgColor());
116: l_main = KeTools.pcmf_stringSubst(l_main, "$VALUE", l_slider
117: .pcmf_getValue().toString());
118:
119: l_main.pcmf_endTR(true);
120:
121: if (l_stepcnt != 0) {
122: Map l_labels = l_slider.pcmf_getLabels();
123:
124: KeStringTemplate l_buffer = new KeStringTemplate("");
125: KeStringTemplate l_bufferMin = null;
126: KeStringTemplate l_bufferMax = null;
127: KeStringTemplate l_step = l_steps_min;
128: Object l_label = null;
129: Integer l_labelKey = new Integer(l_slMin);
130:
131: l_label = l_labels.get(l_labelKey);
132: if (l_label == null)
133: l_label = l_labelKey;
134: else if (l_label instanceof MuGenericComponent)
135: l_label = ((MuGenericComponent) l_label)
136: .pcmf_execView();
137:
138: l_step = KeTools.pcmf_stringSubst(l_step, "$STEP_MIN",
139: l_label.toString());
140: l_bufferMin = l_step;
141:
142: for (int i = l_slMin + l_stepcnt; i < l_slMax; i += l_stepcnt) {
143: l_step = new KeStringTemplate(l_steps);
144: l_labelKey = new Integer(i);
145: l_label = l_labels.get(l_labelKey);
146: if (l_label == null)
147: l_label = l_labelKey;
148: else if (l_label instanceof MuGenericComponent)
149: l_label = ((MuGenericComponent) l_label)
150: .pcmf_execView();
151:
152: l_step = KeTools.pcmf_stringSubst(l_step, "$STEP",
153: l_label.toString());
154: l_buffer = l_buffer.pcmf_stringAddEnd(l_step);
155: }
156: l_step = l_steps_max;
157: l_labelKey = new Integer(l_slMax);
158: l_label = l_labels.get(l_labelKey);
159: if (l_label == null)
160: l_label = l_labelKey;
161: else if (l_label instanceof MuGenericComponent)
162: l_label = ((MuGenericComponent) l_label)
163: .pcmf_execView();
164:
165: l_step = KeTools.pcmf_stringSubst(l_step, "$STEP_MAX",
166: l_label.toString());
167: l_bufferMax = l_step;
168:
169: l_main = KeTools.pcmf_stringSubst(l_main, "$STEPS",
170: l_buffer.toString());
171: l_main = KeTools.pcmf_stringSubst(l_main, "$STEPS_MIN",
172: l_bufferMin.toString());
173: l_main = KeTools.pcmf_stringSubst(l_main, "$STEPS_MAX",
174: l_bufferMax.toString());
175: } else {
176: l_main = KeTools.pcmf_stringSubst(l_main, "$STEPS", "");
177: l_main = KeTools.pcmf_stringSubst(l_main, "$STEPS_MIN", "");
178: l_main = KeTools.pcmf_stringSubst(l_main, "$STEPS_MAX", "");
179: }
180:
181: return (l_main.toString());
182: }
183: }
|