1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
|
package cadtest20060320;
import sun.misc.BASE64Encoder;
import sun.misc.BASE64Decoder;
import javax.swing.*;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.Button;
import java.awt.*;
import java.awt.event.*;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.zip.*;
import java.util.StringTokenizer;
import java.io.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.net.*;
import javax.swing.filechooser.*;
import oracle.forms.ui.VBean;
import oracle.forms.ui.CustomEvent;
import oracle.forms.handler.IHandler;
import oracle.forms.properties.ID;
import oracle.ewt.meter.ProgressBar;
import oracle.ewt.meter.BoundedRangeModelImpl;
import oracle.ewt.thread.TaskScheduler;
import oracle.ewt.thread.Task;
import oracle.ewt.thread.TaskEvent;
import java.beans.PropertyChangeSupport;
import com.cadviewer.*;
public class CADViewerWrapper6 extends VBean
implements RemoteListener
{
private static final ID time = ID.registerProperty ("time");
private static final ID value = ID.registerProperty ("val");
public static final ID changeEvent = ID.registerProperty ("CHANGE");
public static final ID setinit = ID.registerProperty ("INIT");
public static final ID setcodebase = ID.registerProperty ("SETCODEBASE");
public static final ID getmousex = ID.registerProperty ("GETMOUSEX");
public static final ID getmousey = ID.registerProperty ("GETMOUSEY");
private int vx,vy,vw,vh;
public static final ID setviewx = ID.registerProperty ("SETVIEWX");
public static final ID setviewy = ID.registerProperty ("SETVIEWY");
public static final ID setviewwidth = ID.registerProperty ("SETVIEWWIDTH");
public static final ID setviewheight = ID.registerProperty ("SETVIEWHEIGHT");
public static final ID centerview = ID.registerProperty ("CENTERVIEW");
public static final ID getviewwidth = ID.registerProperty ("GETVIEWWIDTH");
public static final ID getviewheight = ID.registerProperty ("GETVIEWHEIGHT");
protected static final ID MOUSEDOWN = ID.registerProperty("MOUSE_DOWN");
static IHandler mHandler;
private Component mComp;
ViewerAWT cadv=null;
private String thecodebasedir = "D:\\CV_AWT_SNCB2006_03_15\\";
private Container contentpane ;
public void init(IHandler handler) {
try {
System.out.println("__START CadWrapper public void init");
// InfoSystem();
System.out.println(" super.init(handler)");
super.init(handler);
System.out.println(" mHandler = handler");
mHandler = handler;
System.out.println("__END CadWrapper public void init");
}
catch (Exception e) {
System.out.println("__EXCEPTION CadWrapper public void init");
e.printStackTrace();
}
}
public CADViewerWrapper6() {
super();
contentpane = this ;
try {
Msg("_____START CADViewerWrapper6() constructor_____");
InitViewer("D:\\CV_AWT_SNCB2006_03_15\\",
"file:///d:/acad_B/es/cat/STIP/Extract/410009.dwf");
this.add(cadv.GetViewerPanel());
this.setVisible(true);
this.setEnabled(true);
Msg("_____END CADViewerWrapper6() constructor_____");
}
catch (Exception e) {
e.printStackTrace();
}
}
//set the delay time for the timer
public boolean setProperty(ID pid, Object value) {
try {
if ( value != null ) {
if ( pid == setcodebase ) {
thecodebasedir = String.valueOf(value);
System.out.println("thecodebasedir="+thecodebasedir);
return true;
}
if ( pid == setinit ) {
System.out.println("setProperty pid == setinit ");
String cad_file = String.valueOf(value);
return true;
}
if ( pid == setviewx ) {
vx = ((Integer)value).intValue();
return true;
}
if ( pid == setviewy ) {
vy = ((Integer)value).intValue();
return true;
}
if ( pid == setviewwidth ) {
vw = ((Integer)value).intValue();
return true;
}
if ( pid == setviewheight ) {
vh = ((Integer)value).intValue();
return true;
}
}
if ( pid == centerview ) {
cadv.centerViewOn_DWG( vx, vy, vw, vh );
return true;
}
}
catch( Exception e ) {
System.out.println("Exception dans setProperty : " + e);
}
return super.setProperty(pid, value);
}
//if the value change, send a msg
public Object getProperty(ID pid) {
try {
if (pid==getmousex) {
String val;
val = Double.toString(cadv.getUnitsX());
return val;
}
if (pid==getmousey) {
String val;
val = Double.toString(cadv.getUnitsY());
return val;
}
if (pid==getviewwidth) {
String val;
val = Integer.toString(cadv.getViewWidth());
return val;
}
if (pid==getviewheight) {
String val;
val = Integer.toString(cadv.getViewHeight());
return val;
}
return "";
}
catch( Exception e ) {
e.printStackTrace();
return null;
}
}
public void Msg( String s ) {
System.out.println(s);
}
public void InitViewer(String codebase, String pFile ) {
try
{
cadv = new ViewerAWT(codebase);
URL url = new URL(pFile);
byte[] arr = cadv.getData(url);
cadv.OpenFile(arr);
Panel p = new Panel();
setSize(1000,500);
cadv.addActionListener((RemoteListener)this);
/*
Get Viewer AWT Panel
*/
p = cadv.GetViewerPanel();
add(p,BorderLayout.CENTER);
}
catch(Exception io)
{
//new MessagePanel(viewerControls.GetMessage("ERROR"),viewerControls.GetMessage("Cannot create parser")+": "+io.toString());
}
}
/**
* Send a message to the Forms module
**/
public void dispatch_event( ID id )
{
CustomEvent ce = new CustomEvent(mHandler, id);
dispatchCustomEvent(ce);
}
public boolean PaintFromComponet() {return true;};
public void doPaint(WidgetGraphics wg,int xMin,double constX,int uMin,int yMin,double constY,int vMin, int maxY)
{ System.out.println("do nothing"); }
public void HandleEventFromRemote(java.awt.Event evt)
{
if(evt.id == evt.MOUSE_DOWN)
{
if ( evt.clickCount == 2) {
System.out.println("mouse pressed");
System.out.println("Screen coord x="+evt.x+",y="+evt.y);
System.out.println("Drawing coord x="+cadv.getX()+",y="+cadv.getY());
System.out.println("last x="+cadv.getUnitsX()+",y="+cadv.getUnitsY());
System.out.println("ViewWidth="+cadv.getViewWidth());
System.out.println("ViewHeight="+cadv.getViewHeight());
System.out.println("______________________________________________");
dispatch_event(MOUSEDOWN);
}
}
}
} |
Partager