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.generic;
032:
033: import java.awt.*;
034:
035: import javax.swing.*;
036:
037: import de.ug2t.channel.markup.html.renderer.*;
038: import de.ug2t.connector.*;
039: import de.ug2t.kernel.*;
040: import de.ug2t.unifiedGui.*;
041: import de.ug2t.unifiedGui.interfaces.*;
042:
043: /**
044: * @author Dirk
045: *
046: * date: 30.01.2005
047: *
048: * <p>
049: * Purpose:
050: * </p>
051: */
052: public class MuGenericSnapShotComponent extends MuGenericComponent
053: implements IUnSnapShotComponent, IKePoolable {
054: private IKeView pem_view = new HtmlSnapShopComponentRenderer();
055: private MuGenericDrawPane pem_dp = null;
056: private Component pem_wdg = null;
057: private int pem_ssHi = 50;
058: private int pem_ssWi = 100;
059:
060: /**
061: * @param xName
062: * @param xTplGetter
063: * @param xTplName
064: * @param xAppl
065: * @throws Exception
066: */
067: public MuGenericSnapShotComponent(String xName,
068: ACoDataGetter xTplGetter, Object xTplName,
069: MuGenericApplication xAppl) throws Exception {
070: super (xName, xTplGetter, xTplName, xAppl);
071: this .pem_dp = (MuGenericDrawPane) this .pcmf_getAppl()
072: .pcmf_getComponentFactory().pcmf_createDrawPane(
073: UnComponentFactory.MARKUP, "MY_DP",
074: this .pem_ssWi, this .pem_ssWi,
075: this .pcmf_getAppl());
076: this .pcmf_setView(pem_view);
077: this .pcmf_setValue("1");
078:
079: this .pem_wdg = new JButton("SnapShot");
080: this .pcmf_commitWidget();
081: }
082:
083: // @@
084:
085: /**
086: * <p>
087: * Does...
088: * </p>
089: * <p>
090: *
091: * @return a Type with
092: * </p>
093: * <p>
094: * @param
095: * </p>
096: */
097: public void pcmf_setSnapShotRoot(Component xWdg) {
098: if (this .pem_wdg != null)
099: IUnSnapShotComponent.VWin.pcmf_remove(this .pem_wdg);
100:
101: this .pem_wdg = xWdg;
102: }
103:
104: /**
105: * <p>
106: * Does...
107: * </p>
108: * <p>
109: *
110: * @return a Type with
111: * </p>
112: * <p>
113: * @param
114: * </p>
115: */
116: public void pcmf_setWidgetSize(int x, int y) {
117: this .pem_ssWi = x;
118: this .pem_ssHi = y;
119: }
120:
121: /**
122: * <p>
123: * Does...
124: * </p>
125: * <p>
126: *
127: * @return a Type with
128: * </p>
129: * <p>
130: * @param
131: * </p>
132: */
133: public int pcmf_getWidgetSizeX() {
134: return (this .pem_ssWi);
135: }
136:
137: /**
138: * <p>
139: * Does...
140: * </p>
141: * <p>
142: *
143: * @return a Type with
144: * </p>
145: * <p>
146: * @param
147: * </p>
148: */
149: public int pcmf_getWidgetSizeY() {
150: return (this .pem_ssHi);
151: }
152:
153: public void pcmf_setFixedSize(int w, int h, int type) {
154: this .pcmf_setWidgetSize(w, h);
155: super .pcmf_setFixedSize(w, h, type);
156: }
157:
158: /**
159: * <p>
160: * Does...
161: * </p>
162: * <p>
163: *
164: * @return a Type with
165: * </p>
166: * <p>
167: * @param
168: * </p>
169: */
170: public void pcmf_setBgColor(String xCol) {
171: try {
172: if (xCol.charAt(0) == '#') {
173: xCol = xCol.substring(1, xCol.length());
174: int r = Integer.parseInt(xCol.substring(0, 2), 16);
175: int g = Integer.parseInt(xCol.substring(2, 4), 16);
176: int b = Integer.parseInt(xCol.substring(4, 6), 16);
177: this .pem_wdg.setForeground(new Color(r, g, b));
178: } else
179: this .pem_wdg.setBackground((Color) java.awt.Color.class
180: .getDeclaredField(xCol).get(null));
181: } catch (Exception e) {
182: KeLog.pcmf_logException("ug2t", this , e);
183: }
184: ;
185:
186: super .pcmf_setBgColor(xCol);
187:
188: return;
189: }
190:
191: /**
192: * <p>
193: * Does...
194: * </p>
195: * <p>
196: *
197: * @return a Type with
198: * </p>
199: * <p>
200: * @param
201: * </p>
202: */
203: public void pcmf_setFgColor(String xCol) {
204: try {
205: if (xCol.charAt(0) == '#') {
206: xCol = xCol.substring(1, xCol.length());
207: int r = Integer.parseInt(xCol.substring(0, 2), 16);
208: int g = Integer.parseInt(xCol.substring(2, 4), 16);
209: int b = Integer.parseInt(xCol.substring(4, 6), 16);
210: this .pem_wdg.setForeground(new Color(r, g, b));
211: } else
212: this .pem_wdg.setForeground((Color) java.awt.Color.class
213: .getDeclaredField(xCol).get(null));
214: } catch (Exception e) {
215: KeLog.pcmf_logException("ug2t", this , e);
216: }
217: ;
218:
219: super .pcmf_setFgColor(xCol);
220:
221: return;
222: }
223:
224: /**
225: * <p>
226: * Does...
227: * </p>
228: * <p>
229: *
230: * @return a Type with
231: * </p>
232: * <p>
233: * @param
234: * </p>
235: */
236: public void pcmf_setFont(UnFontDescriptor xFont) {
237: Font l_font = Font.getFont(xFont.pcmf_getFontFullSpec(),
238: new Font(null, xFont.pcmf_getFontStyle(), xFont
239: .pcmf_getFontSize()));
240: this .pem_wdg.setFont(l_font);
241: super .pcmf_setFont(xFont);
242:
243: return;
244: }
245:
246: public Object pcmf_getSSWdgOutPut() {
247: this .pem_wdg.setSize(this .pem_ssWi, this .pem_ssHi);
248: IUnSnapShotComponent.VWin.pcmf_remove(this .pem_wdg);
249: IUnSnapShotComponent.VWin.pcmf_add(this .pem_wdg);
250:
251: this .pem_dp.pcmf_setDrawPaneSize(this .pem_ssWi, this .pem_ssHi);
252:
253: this .pem_dp.pcmf_clearDrawPane();
254: this .pem_wdg.print(this .pem_dp.pcmf_getGraphics());
255: this .pem_dp.pcmf_commitDrawPane();
256:
257: return (this .pem_dp.pcmf_execView());
258: }
259:
260: public void pcmf_delete() throws Exception {
261: if (this .pdm_deleted == true)
262: return;
263:
264: this .pem_dp.pcmf_delete();
265:
266: if (this .pem_wdg != null)
267: IUnSnapShotComponent.VWin.pcmf_remove(this .pem_wdg);
268:
269: super .pcmf_delete();
270: };
271:
272: public void pcmf_commitWidget() {
273: return;
274: }
275:
276: // @@
277: }
|