Commit 82846444 authored by Claes Sjofors's avatar Claes Sjofors

jopg second commit

parent 1b8c2a17
This diff is collapsed.
...@@ -39,7 +39,8 @@ package jpwr.jopg; ...@@ -39,7 +39,8 @@ package jpwr.jopg;
public class Glow { public class Glow {
public static final int GLOW__TERMINATED = 21001; public static final int GLOW__TERMINATED = 21001;
public static final int GLOW__SUBTERMINATED = 21003; public static final int GLOW__SUBTERMINATED = 21003;
public static final int GLOW__NO_PROPAGATE = 21005;
public static final int DRAW_MP = 6; public static final int DRAW_MP = 6;
public static final int DRAW_TYPE_SIZE = 9; public static final int DRAW_TYPE_SIZE = 9;
...@@ -1466,10 +1467,16 @@ public class Glow { ...@@ -1466,10 +1467,16 @@ public class Glow {
public static final int ePosition_Absolute = 0; public static final int ePosition_Absolute = 0;
public static final int ePosition_Relative = 1; public static final int ePosition_Relative = 1;
public static final int eEventType_Object = 0;
public static final int eEventType_Menu = 1;
public static final int eEvent_MB1Click = 0; public static final int eEvent_MB1Click = 0;
public static final int eEvent_MB1Up = 2; public static final int eEvent_MB1Up = 2;
public static final int eEvent_MB1Down = 3; public static final int eEvent_MB1Down = 3;
public static final int eEvent_MB1DoubleClick = 4; public static final int eEvent_MB1DoubleClick = 4;
public static final int eEvent_CursorMotion = 5; public static final int eEvent_CursorMotion = 5;
public static final int eEvent_ValueChanged = 7; public static final int eEvent_ValueChanged = 7;
public static final int eEvent_MenuCreate = 8;
public static final int eEvent_MenuActivated = 9;
public static final int eEvent_MenuDelete = 10;
} }
...@@ -43,4 +43,5 @@ public class GlowArrayElem { ...@@ -43,4 +43,5 @@ public class GlowArrayElem {
public void draw() {} public void draw() {}
public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {} public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {}
public int eventHandler(GlowEvent e, double fx, double fy) {return 0;} public int eventHandler(GlowEvent e, double fx, double fy) {return 0;}
public Object getUserData() { return null;}
} }
...@@ -461,4 +461,13 @@ public class GlowDraw implements GlowDrawIfc { ...@@ -461,4 +461,13 @@ public class GlowDraw implements GlowDrawIfc {
} }
return fonts[idx]; return fonts[idx];
} }
public int set_clip_rectangle( int x1, int y1, int x2, int y2) {
g2.setClip(new Rectangle2D.Float((float)x1, (float)y1, (float)x2, (float)y2));
return 1;
}
public void reset_clip_rectangle() {
g2.setClip(null);
}
} }
...@@ -57,4 +57,6 @@ public interface GlowDrawIfc { ...@@ -57,4 +57,6 @@ public interface GlowDrawIfc {
public int gradient_rotate(double rotate, int gradient); public int gradient_rotate(double rotate, int gradient);
public GlowDimension getTextExtent( String text, int idx, int type); public GlowDimension getTextExtent( String text, int idx, int type);
public Color getColor(int gc_type); public Color getColor(int gc_type);
public int set_clip_rectangle( int x1, int y1, int x2, int y2);
public void reset_clip_rectangle();
} }
/* /*
* Proview Open Source Process Control. * Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB. * Copyright (C) 2005-2012 SSAB EMEA AB.
* *
...@@ -37,10 +37,12 @@ ...@@ -37,10 +37,12 @@
package jpwr.jopg; package jpwr.jopg;
public class GlowEvent { public class GlowEvent {
public int event;
public int type; public int type;
public double x; public double x;
public double y; public double y;
Object object; public GlowArrayElem object;
public int object_type;
public GlowEvent() {} public GlowEvent() {}
} }
\ No newline at end of file
...@@ -49,6 +49,10 @@ public class GlowPoint { ...@@ -49,6 +49,10 @@ public class GlowPoint {
this.cmn = cmn; this.cmn = cmn;
} }
public void posit(double x, double y) {
this.x = x;
this.y = y;
}
public void open(BufferedReader reader) { public void open(BufferedReader reader) {
String line; String line;
StringTokenizer token; StringTokenizer token;
......
...@@ -57,6 +57,10 @@ public class GlowTransform { ...@@ -57,6 +57,10 @@ public class GlowTransform {
boolean stored; boolean stored;
public GlowTransform() { public GlowTransform() {
a11 = 1;
a22 = 1;
s_a11 = 1;
s_a22 = 1;
} }
public void store() { public void store() {
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
package jpwr.jopg; package jpwr.jopg;
import jpwr.rt.*; import jpwr.rt.*;
import java.io.*; import java.io.*;
import java.util.*;
public class Graph implements GraphIfc, GrowApplIfc { public class Graph implements GraphIfc, GrowApplIfc {
public static final int eType_Bit = (1 << 15) + 1; public static final int eType_Bit = (1 << 15) + 1;
...@@ -61,6 +62,12 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -61,6 +62,12 @@ public class Graph implements GraphIfc, GrowApplIfc {
cmn.setGdraw(gdraw); cmn.setGdraw(gdraw);
} }
public int getWidth() {
return appl.getWidth();
}
public int getHeight() {
return appl.getHeight();
}
public Gdh getGdh() { public Gdh getGdh() {
return gdh; return gdh;
} }
...@@ -158,6 +165,9 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -158,6 +165,9 @@ public class Graph implements GraphIfc, GrowApplIfc {
} }
public DynParsedAttrName parseAttrName( String name) { public DynParsedAttrName parseAttrName( String name) {
if ( name == null)
return null;
int idx, tidx, eidx; int idx, tidx, eidx;
DynParsedAttrName pname = new DynParsedAttrName(); DynParsedAttrName pname = new DynParsedAttrName();
...@@ -222,10 +232,74 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -222,10 +232,74 @@ public class Graph implements GraphIfc, GrowApplIfc {
} }
public void eventHandler(GlowEvent e) { public void eventHandler(GlowEvent e) {
if ( e.object != null) { switch ( e.event) {
int sts; case Glow.eEvent_MB1Click:
Dyn dyn = (Dyn)((GrowNode)e.object).getUserData(); if ( e.object_type == Glow.eObjectType_NoObject ||
sts = dyn.action((GrowNode)e.object, e); e.object.type() != Glow.eObjectType_GrowMenu) {
// Close any open menu, if not click in menu
GlowEventMenu event = new GlowEventMenu();
event.event = Glow.eEvent_MenuDelete;
event.type = Glow.eEventType_Menu;
event.object = null;
System.out.println("Graph: delete any menu");
Vector<GlowArrayElem> list = ctx.get_object_list();
for ( int i = 0; i < list.size(); i++) {
GlowArrayElem o = list.get(i);
if ( (o.type() == Glow.eObjectType_GrowNode ||
o.type() == Glow.eObjectType_GrowGroup) &&
(e.object_type == Glow.eObjectType_NoObject ||
o != e.object)) {
Dyn dyn = (Dyn)o.getUserData();
if ( dyn != null)
dyn.action( (GrowNode)o, (GlowEvent)event);
int old_size = list.size();
list = ctx.get_object_list();
if ( old_size != list.size())
// Something is deleted
break;
}
}
}
// Note! no break
case Glow.eEvent_MB1Up:
case Glow.eEvent_MB1Down:
case Glow.eEvent_ValueChanged:
if ( e.object != null) {
int sts;
Dyn dyn = (Dyn)((GlowArrayElem)e.object).getUserData();
if ( dyn != null)
sts = dyn.action((GrowNode)e.object, e);
}
break;
case Glow.eEvent_MenuActivated:
case Glow.eEvent_MenuCreate:
case Glow.eEvent_MenuDelete: {
int old_size;
int sts;
Vector<GlowArrayElem> list = ctx.get_object_list();
for ( int i = 0; i < list.size(); i++) {
GlowArrayElem o = list.get(i);
if ( o.type() == Glow.eObjectType_GrowNode ||
o.type() == Glow.eObjectType_GrowGroup) {
Dyn dyn = (Dyn)o.getUserData();
if ( dyn != null) {
sts = dyn.action((GrowNode)o, e);
if ( sts == Glow.GLOW__TERMINATED)
return;
// Check if anything is deleted
old_size = list.size();
list = ctx.get_object_list();
if ( old_size != list.size())
break;
}
}
}
break;
}
} }
} }
......
...@@ -39,4 +39,6 @@ package jpwr.jopg; ...@@ -39,4 +39,6 @@ package jpwr.jopg;
public interface GraphApplIfc { public interface GraphApplIfc {
public int command(String cmd); public int command(String cmd);
public void openConfirmDialog( Object dyn, String text, Object object); public void openConfirmDialog( Object dyn, String text, Object object);
public int getWidth();
public int getHeight();
} }
...@@ -43,4 +43,6 @@ public interface GrowApplIfc { ...@@ -43,4 +43,6 @@ public interface GrowApplIfc {
public void traceDisconnect(GrowNode object); public void traceDisconnect(GrowNode object);
public void traceScan(GrowNode object); public void traceScan(GrowNode object);
public void eventHandler(GlowEvent e); public void eventHandler(GlowEvent e);
public int getWidth();
public int getHeight();
} }
...@@ -241,7 +241,7 @@ public class GrowArc extends GlowArrayElem { ...@@ -241,7 +241,7 @@ public class GrowArc extends GlowArrayElem {
public int eventHandler( GlowEvent event, double fx, double fy) { public int eventHandler( GlowEvent event, double fx, double fy) {
GlowPoint rp; GlowPoint rp;
switch ( event.type) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
return 0; return 0;
default: ; default: ;
...@@ -251,8 +251,6 @@ public class GrowArc extends GlowArrayElem { ...@@ -251,8 +251,6 @@ public class GrowArc extends GlowArrayElem {
//rp = new GlowPoint(null); //rp = new GlowPoint(null);
//rp.x = fx; //rp.x = fx;
//rp.y = fy; //rp.y = fy;
System.out.println( "Event handler: " + fx + " " + fy + " reverse: " + rp.x + " " + rp.y);
System.out.println( " ll: " + ll.x + " " + ll.y + " ur: " + ur.x + " " + ur.y);
if ( ll.x <= rp.x && rp.x <= ur.x && if ( ll.x <= rp.x && rp.x <= ur.x &&
ll.y <= rp.y && rp.y <= ur.y) { ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in arc"); System.out.println( "Event handler: Hit in arc");
......
...@@ -49,6 +49,10 @@ public class GrowCmn { ...@@ -49,6 +49,10 @@ public class GrowCmn {
public double base_zoom_factor; public double base_zoom_factor;
public int offset_x; public int offset_x;
public int offset_y; public int offset_y;
public int window_width;
public int window_height;
public int subwindow_x;
public int subwindow_y;
} }
public GrowApplIfc appl; public GrowApplIfc appl;
...@@ -96,6 +100,9 @@ public class GrowCmn { ...@@ -96,6 +100,9 @@ public class GrowCmn {
int hot_indication; int hot_indication;
Object userdata; Object userdata;
GlowArrayElem callback_object; GlowArrayElem callback_object;
int callback_object_type;
int hot_mode;
int hot_found;
Vector<GlowArrayElem> a = new Vector<GlowArrayElem>(); Vector<GlowArrayElem> a = new Vector<GlowArrayElem>();
Vector<GlowArrayElem> a_nc = new Vector<GlowArrayElem>(); Vector<GlowArrayElem> a_nc = new Vector<GlowArrayElem>();
...@@ -106,8 +113,16 @@ public class GrowCmn { ...@@ -106,8 +113,16 @@ public class GrowCmn {
this.appl = appl; this.appl = appl;
this.debug = true; this.debug = true;
this.antiAliasing = true; this.antiAliasing = true;
mw.window_width = getWidth();
mw.window_height = getHeight();
} }
public int getWidth() {
return appl.getWidth();
}
public int getHeight() {
return appl.getHeight();
}
public void setGdraw(GlowDrawIfc gdraw) { public void setGdraw(GlowDrawIfc gdraw) {
this.gdraw = gdraw; this.gdraw = gdraw;
} }
......
...@@ -349,12 +349,33 @@ public class GrowCtx implements GrowCtxIfc { ...@@ -349,12 +349,33 @@ public class GrowCtx implements GrowCtxIfc {
} }
} }
public void register_callback_object(GlowArrayElem o) { public void register_callback_object(int type, GlowArrayElem o) {
cmn.callback_object = o; cmn.callback_object = o;
cmn.callback_object_type = type;
} }
public int send_menu_callback( GlowArrayElem object, int item, int event,
double x, double y) {
/* Send a host request callback */
GlowEventMenu e = new GlowEventMenu();
e.event = event;
e.type = Glow.eEventType_Menu;
// e.any.x_pixel = int( x * mw.zoom_factor_x) - mw.offset_x;
// e.any.y_pixel = int( y * mw.zoom_factor_y) - mw.offset_y;
e.x = x;
e.y = y;
e.object_type = object.type();
e.object = object;
e.item = item;
cmn.appl.eventHandler(e);
return 1;
}
public void eventHandler(GlowEvent e) { public void eventHandler(GlowEvent e) {
int sts = 0; int sts = 0;
cmn.callback_object = null; cmn.callback_object = null;
cmn.callback_object_type = Glow.eObjectType_NoObject;
for ( int i = cmn.a.size() - 1; i >= 0; i--) { for ( int i = cmn.a.size() - 1; i >= 0; i--) {
sts = ((GlowArrayElem)cmn.a.get(i)).eventHandler(e, e.x, e.y); sts = ((GlowArrayElem)cmn.a.get(i)).eventHandler(e, e.x, e.y);
if ( sts == 1) { if ( sts == 1) {
...@@ -364,6 +385,7 @@ public class GrowCtx implements GrowCtxIfc { ...@@ -364,6 +385,7 @@ public class GrowCtx implements GrowCtxIfc {
if ( sts == 1 && cmn.appl != null) { if ( sts == 1 && cmn.appl != null) {
e.object = cmn.callback_object; e.object = cmn.callback_object;
e.object_type = cmn.callback_object_type;
cmn.appl.eventHandler(e); cmn.appl.eventHandler(e);
} }
} }
...@@ -446,6 +468,18 @@ public class GrowCtx implements GrowCtxIfc { ...@@ -446,6 +468,18 @@ public class GrowCtx implements GrowCtxIfc {
return null; return null;
} }
public void insert(GlowArrayElem e) {
cmn.a.add(e);
}
public void remove(GlowArrayElem e) {
cmn.a.remove(e);
}
public void pop(GlowArrayElem e) {
// TODO
}
public Vector<GlowArrayElem> get_object_list() {
return cmn.a;
}
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
*/ */
package jpwr.jopg; package jpwr.jopg;
import java.util.*;
public interface GrowCtxIfc { public interface GrowCtxIfc {
...@@ -42,5 +43,11 @@ public interface GrowCtxIfc { ...@@ -42,5 +43,11 @@ public interface GrowCtxIfc {
public GlowArrayElem get_object_group( GlowArrayElem object); public GlowArrayElem get_object_group( GlowArrayElem object);
public void draw(); public void draw();
public void draw( double ll_x, double ll_y, double ur_x, double ur_y); public void draw( double ll_x, double ll_y, double ur_x, double ur_y);
public void register_callback_object(GlowArrayElem o); public void register_callback_object(int type, GlowArrayElem o);
public int send_menu_callback( GlowArrayElem object, int item, int type,
double x, double y);
public void insert(GlowArrayElem e);
public void remove(GlowArrayElem e);
public void pop(GlowArrayElem e);
public Vector<GlowArrayElem> get_object_list();
} }
...@@ -129,14 +129,14 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener { ...@@ -129,14 +129,14 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
setSize(); setSize();
enableEvents(AWTEvent.WINDOW_EVENT_MASK); enableEvents(AWTEvent.WINDOW_EVENT_MASK);
setDefaultCloseOperation( DISPOSE_ON_CLOSE); setDefaultCloseOperation( DISPOSE_ON_CLOSE);
localPanel.addMouseListener(new MouseAdapter() { MouseAdapter adapter = new MouseAdapter() {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
System.out.println("MouseListener"); System.out.println("MouseListener");
GlowEvent event = new GlowEvent(); GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x; event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y; event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.type = Glow.eEvent_MB1Click; event.event = Glow.eEvent_MB1Click;
graph.ctx.eventHandler( event); graph.ctx.eventHandler( event);
} }
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
...@@ -144,7 +144,7 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener { ...@@ -144,7 +144,7 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
GlowEvent event = new GlowEvent(); GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x; event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y; event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.type = Glow.eEvent_MB1Down; event.event = Glow.eEvent_MB1Down;
graph.ctx.eventHandler( event); graph.ctx.eventHandler( event);
} }
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
...@@ -152,23 +152,33 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener { ...@@ -152,23 +152,33 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
GlowEvent event = new GlowEvent(); GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x; event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y; event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.type = Glow.eEvent_MB1Up; event.event = Glow.eEvent_MB1Up;
graph.ctx.eventHandler( event); graph.ctx.eventHandler( event);
} }
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
System.out.println("MouseListener");
GlowEvent event = new GlowEvent(); GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x; event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y; event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.type = Glow.eEvent_CursorMotion; event.event = Glow.eEvent_CursorMotion;
graph.ctx.eventHandler( event); graph.ctx.eventHandler( event);
} }
}); };
localPanel.addMouseListener(adapter);
localPanel.addMouseMotionListener(adapter);
timer = new Timer( scanTime, this); timer = new Timer( scanTime, this);
timer.start(); timer.start();
} }
public int getWidth() {
return localPanel.getWidth();
}
public int getHeight() {
return localPanel.getHeight();
}
public void actionPerformed( ActionEvent e) { public void actionPerformed( ActionEvent e) {
scanCount++; scanCount++;
if ( scanCount == 1) if ( scanCount == 1)
......
...@@ -181,15 +181,13 @@ public class GrowLine extends GlowArrayElem { ...@@ -181,15 +181,13 @@ public class GrowLine extends GlowArrayElem {
/* /*
GlowPoint rp; GlowPoint rp;
switch ( event.type) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
return 0; return 0;
default: ; default: ;
} }
rp = trf.reverse( fx, fy); rp = trf.reverse( fx, fy);
System.out.println( "Event handler: " + fx + " " + fy + " reverse: " + rp.x + " " + rp.y);
System.out.println( " ll: " + ll.x + " " + ll.y + " ur: " + ur.x + " " + ur.y);
if ( ll.x <= rp.x && rp.x <= ur.x && if ( ll.x <= rp.x && rp.x <= ur.x &&
ll.y <= rp.y && rp.y <= ur.y) { ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in rect"); System.out.println( "Event handler: Hit in rect");
......
...@@ -93,6 +93,9 @@ public class GrowNode extends GlowArrayElem { ...@@ -93,6 +93,9 @@ public class GrowNode extends GlowArrayElem {
public int input_selected; public int input_selected;
public int annotv_inputmode[] = new int[10]; public int annotv_inputmode[] = new int[10];
public double fill_level = 1; public double fill_level = 1;
public int level_fill_drawtype;
public int level_color_tone;
public int level_direction;
GrowCmn cmn; GrowCmn cmn;
...@@ -343,7 +346,7 @@ public class GrowNode extends GlowArrayElem { ...@@ -343,7 +346,7 @@ public class GrowNode extends GlowArrayElem {
GlowPoint rp; GlowPoint rp;
int sts; int sts;
switch ( event.type) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
return 0; return 0;
default: ; default: ;
...@@ -354,12 +357,10 @@ public class GrowNode extends GlowArrayElem { ...@@ -354,12 +357,10 @@ public class GrowNode extends GlowArrayElem {
if ( sts != 0) { if ( sts != 0) {
System.out.println( "Hit in node " + sts); System.out.println( "Hit in node " + sts);
if ( type() != Glow.eObjectType_GrowGroup) if ( type() != Glow.eObjectType_GrowGroup)
cmn.ctx.register_callback_object(this); cmn.ctx.register_callback_object(Glow.eObjectType_Node, this);
return sts; return sts;
} }
/* /*
System.out.println( "Event handler: " + fx + " " + fy + " reverse: " + rp.x + " " + rp.y);
System.out.println( " ll: " + ll.x + " " + ll.y + " ur: " + ur.x + " " + ur.y);
if ( ll.x <= rp.x && rp.x <= ur.x && if ( ll.x <= rp.x && rp.x <= ur.x &&
ll.y <= rp.y && rp.y <= ur.y) { ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in rect"); System.out.println( "Event handler: Hit in rect");
...@@ -372,7 +373,8 @@ public class GrowNode extends GlowArrayElem { ...@@ -372,7 +373,8 @@ public class GrowNode extends GlowArrayElem {
public void draw() { public void draw() {
if ( visible != 0) if ( visible != 0)
nc.draw( trf, highlight, hot, this, this); //nc.draw( trf, highlight, hot, this, this);
draw(null, highlight, hot, null, null);
} }
public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) { public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {
...@@ -396,7 +398,145 @@ public class GrowNode extends GlowArrayElem { ...@@ -396,7 +398,145 @@ public class GrowNode extends GlowArrayElem {
else else
nc.draw( trf, highlight, hot, node, node); nc.draw( trf, highlight, hot, node, node);
} }
else {
int x1, x2, y1, y2;
int x_level = 0;
int y_level = 0;
int clip_sts = 0;
int old_color_tone = 0;
int old_fill_drawtype = 0;
if (t == null) {
x1 = (int)( x_left * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
y1 = (int)( y_low * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
x2 = (int)( x_right * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
y2 = (int)( y_high * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
}
else {
x1 = (int)( t.x( x_left, y_low) * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
y1 = (int)( t.y( x_left, y_low) * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
x2 = (int)( t.x( x_right, y_high) * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
y2 = (int)( t.y( x_right, y_high) * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
}
switch ( level_direction) {
case Glow.eDirection_Right:
x_level = (int)( fill_level * (x2 - x1) + 0.5);
clip_sts = cmn.gdraw.set_clip_rectangle( x1 - 1, y1 - 1, x1 + x_level, y2 + 1);
break;
case Glow.eDirection_Left:
x_level = (int)( (1 - fill_level) * ( x2 - x1) + 0.5);
clip_sts = cmn.gdraw.set_clip_rectangle( x1 - 1, y1 - 1, x1 + x_level, y2 + 1);
if ( level_color_tone != Glow.eDrawTone_No) {
old_color_tone = color_tone;
color_tone = level_color_tone;
}
else if ( level_fill_drawtype != Glow.eDrawType_No) {
old_fill_drawtype = fill_drawtype;
fill_drawtype = level_fill_drawtype;
}
break;
case Glow.eDirection_Up:
y_level = (int)( fill_level * (y2 - y1) + 0.5);
clip_sts = cmn.gdraw.set_clip_rectangle( x1 - 1, y1 - 1, x2 + 1, y1 + y_level);
break;
case Glow.eDirection_Down:
y_level = (int)( (1 - fill_level) * ( y2 - y1) + 0.5);
clip_sts = cmn.gdraw.set_clip_rectangle( x1 - 1, y1 - 1, x2 + 1, y1 + y_level);
if ( level_color_tone != Glow.eDrawTone_No) {
old_color_tone = color_tone;
color_tone = level_color_tone;
}
else if ( level_fill_drawtype != Glow.eDrawType_No) {
old_fill_drawtype = fill_drawtype;
fill_drawtype = level_fill_drawtype;
}
break;
default: ;
}
if ( t != null) {
GlowTransform trf_tot = t.multiply( trf);
// If this node has a trace pointer, use colors for this node
nc.draw( trf_tot, highlight, hot, this, this);
}
else
nc.draw( trf, highlight, hot, node, node);
if ( (clip_sts & 1) != 0)
cmn.gdraw.reset_clip_rectangle();
switch ( level_direction) {
case Glow.eDirection_Right:
if ( level_color_tone != Glow.eDrawTone_No) {
old_color_tone = color_tone;
color_tone = level_color_tone;
}
else if ( level_fill_drawtype != Glow.eDrawType_No) {
old_fill_drawtype = fill_drawtype;
fill_drawtype = level_fill_drawtype;
}
clip_sts = cmn.gdraw.set_clip_rectangle( x1 + x_level, y1 - 1, x2 + 1, y2 + 1);
break;
case Glow.eDirection_Left:
if ( level_color_tone != Glow.eDrawTone_No)
color_tone = old_color_tone;
else if ( level_fill_drawtype != Glow.eDrawType_No)
fill_drawtype = old_fill_drawtype;
clip_sts = cmn.gdraw.set_clip_rectangle( x1 + x_level, y1 - 1, x2 + 1, y2 + 1);
break;
case Glow.eDirection_Up:
if ( level_color_tone != Glow.eDrawTone_No) {
old_color_tone = color_tone;
color_tone = level_color_tone;
}
else if ( level_fill_drawtype != Glow.eDrawType_No) {
old_fill_drawtype = fill_drawtype;
fill_drawtype = level_fill_drawtype;
}
clip_sts = cmn.gdraw.set_clip_rectangle( x1 - 1, y1 + y_level, x2 + 1, y2 + 1);
break;
case Glow.eDirection_Down:
if ( level_color_tone != Glow.eDrawTone_No)
color_tone = old_color_tone;
else if ( level_fill_drawtype != Glow.eDrawType_No)
fill_drawtype = old_fill_drawtype;
clip_sts = cmn.gdraw.set_clip_rectangle( x1 - 1, y1 + y_level, x2 + 1, y2 + 1);
break;
default: ;
}
if ( t != null) {
GlowTransform trf_tot = t.multiply( trf);
// If this node has a trace pointer, use colors for this node
nc.draw( trf_tot, highlight, hot, this, this);
}
else
nc.draw( trf, highlight, hot, node, node);
if ( (clip_sts & 1) != 0)
cmn.gdraw.reset_clip_rectangle();
switch ( level_direction) {
case Glow.eDirection_Right:
if ( level_color_tone != Glow.eDrawTone_No)
color_tone = old_color_tone;
else if ( level_fill_drawtype != Glow.eDrawType_No)
fill_drawtype = old_fill_drawtype;
break;
case Glow.eDirection_Left:
break;
case Glow.eDirection_Up:
if ( level_color_tone != Glow.eDrawTone_No)
color_tone = old_color_tone;
else if ( level_fill_drawtype != Glow.eDrawType_No)
fill_drawtype = old_fill_drawtype;
break;
case Glow.eDirection_Down:
break;
default: ;
}
}
} }
public int getClassTraceColor1() { public int getClassTraceColor1() {
...@@ -444,6 +584,18 @@ public class GrowNode extends GlowArrayElem { ...@@ -444,6 +584,18 @@ public class GrowNode extends GlowArrayElem {
public void setColorInverse(int color_inverse) { public void setColorInverse(int color_inverse) {
this.color_inverse = color_inverse; this.color_inverse = color_inverse;
} }
public void setLevelFillColor(int color) {
level_fill_drawtype = color;
}
public void setLevelColorTone(int tone) {
level_color_tone = tone;
}
public void setLevelDirection( int level_direction) {
this.level_direction = level_direction;
}
public void setFillLevel(double fill_level) {
this.fill_level = fill_level;
}
public String getAnnotation(int number) { public String getAnnotation(int number) {
return annotv[number]; return annotv[number];
} }
...@@ -588,4 +740,63 @@ public class GrowNode extends GlowArrayElem { ...@@ -588,4 +740,63 @@ public class GrowNode extends GlowArrayElem {
old_x_right * cmn.mw.zoom_factor_x - cmn.mw.offset_x + Glow.DRAW_MP, old_x_right * cmn.mw.zoom_factor_x - cmn.mw.offset_x + Glow.DRAW_MP,
old_y_high * cmn.mw.zoom_factor_y - cmn.mw.offset_y + Glow.DRAW_MP); old_y_high * cmn.mw.zoom_factor_y - cmn.mw.offset_y + Glow.DRAW_MP);
} }
public GlowFillLevelLimits getLimits()
{
GlowFillLevelLimits limits = new GlowFillLevelLimits();
if ( nc.y0 == 0 && nc.y1 == 0) {
limits.status = 0;
return limits;
}
if ( !(nc.x0 == 0 && nc.x1 == 0)) {
limits.status = 0;
return limits;
}
double x1, x2, y1, y2;
double rotation;
// Calculate max and min koordinates
x1 = trf.x( 0, nc.y0);
y1 = trf.y( 0, nc.y0);
x2 = trf.x( 0, nc.y1);
y2 = trf.y( 0, nc.y1);
rotation = (trf.rot() / 360 - Math.floor( trf.rot() / 360)) * 360;
if ( 45 >= rotation || rotation > 315) {
limits.direction = Glow.eDirection_Down;
limits.min = y1;
limits.max = y2;
}
else if ( 45 < rotation && rotation <= 135) {
limits.direction = Glow.eDirection_Right;
limits.min = x2;
limits.max = x1;
}
else if ( 135 < rotation && rotation <= 225) {
limits.direction = Glow.eDirection_Up;
limits.min = y2;
limits.max = y1;
}
else if ( 225 < rotation && rotation <= 315) {
limits.direction = Glow.eDirection_Left;
limits.min = x1;
limits.max = x2;
}
limits.status = 1;
return limits;
}
public GlowGeometry measure() {
GlowGeometry geom = new GlowGeometry();
geom.ll_x = x_left;
geom.ll_y = y_low;
geom.ur_x = x_right;
geom.ur_y = y_high;
return geom;
}
} }
...@@ -256,7 +256,7 @@ public class GrowPolyline extends GlowArrayElem { ...@@ -256,7 +256,7 @@ public class GrowPolyline extends GlowArrayElem {
/* /*
GlowPoint rp; GlowPoint rp;
switch ( event.type) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
return 0; return 0;
default: ; default: ;
...@@ -266,8 +266,6 @@ public class GrowPolyline extends GlowArrayElem { ...@@ -266,8 +266,6 @@ public class GrowPolyline extends GlowArrayElem {
//rp = new GlowPoint(null); //rp = new GlowPoint(null);
//rp.x = fx; //rp.x = fx;
//rp.y = fy; //rp.y = fy;
System.out.println( "Event handler: " + fx + " " + fy + " reverse: " + rp.x + " " + rp.y);
System.out.println( " ll: " + ll.x + " " + ll.y + " ur: " + ur.x + " " + ur.y);
if ( ll.x <= rp.x && rp.x <= ur.x && if ( ll.x <= rp.x && rp.x <= ur.x &&
ll.y <= rp.y && rp.y <= ur.y) { ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in polyline"); System.out.println( "Event handler: Hit in polyline");
......
...@@ -78,6 +78,33 @@ public class GrowRect extends GlowArrayElem { ...@@ -78,6 +78,33 @@ public class GrowRect extends GlowArrayElem {
ur = new GlowPoint(cmn); ur = new GlowPoint(cmn);
} }
public GrowRect( GrowCmn cmn, String n_name, double x, double y,
double w, double h, int draw_type, int line_width,
int fill, int border, int shadow,
int fill_drawtype) {
this.cmn = cmn;
trf = new GlowTransform();
ll = new GlowPoint(cmn);
ll.x = x;
ll.y = y;
ur = new GlowPoint(cmn);
ur.x = x + w;
ur.y = y + h;
this.draw_type = draw_type;
this.line_width = line_width;
this.fill = fill;
this.border = border;
this.shadow = shadow;
this.fill_drawtype = fill_drawtype;
this.n_name = n_name;
shadow_width = 5;
relief = Glow.eRelief_Up;
shadow_contrast = 2;
gradient = Glow.eGradient_No;
gradient_contrast = 4;
}
public int type() { public int type() {
return Glow.eObjectType_GrowRect; return Glow.eObjectType_GrowRect;
} }
...@@ -240,7 +267,7 @@ public class GrowRect extends GlowArrayElem { ...@@ -240,7 +267,7 @@ public class GrowRect extends GlowArrayElem {
public int eventHandler( GlowEvent event, double fx, double fy) { public int eventHandler( GlowEvent event, double fx, double fy) {
GlowPoint rp; GlowPoint rp;
switch ( event.type) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
return 0; return 0;
default: ; default: ;
...@@ -250,8 +277,6 @@ public class GrowRect extends GlowArrayElem { ...@@ -250,8 +277,6 @@ public class GrowRect extends GlowArrayElem {
//rp = new GlowPoint(null); //rp = new GlowPoint(null);
//rp.x = fx; //rp.x = fx;
//rp.y = fy; //rp.y = fy;
System.out.println( "Event handler: " + fx + " " + fy + " reverse: " + rp.x + " " + rp.y);
System.out.println( " ll: " + ll.x + " " + ll.y + " ur: " + ur.x + " " + ur.y);
if ( ll.x <= rp.x && rp.x <= ur.x && if ( ll.x <= rp.x && rp.x <= ur.x &&
ll.y <= rp.y && rp.y <= ur.y) { ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in rect"); System.out.println( "Event handler: Hit in rect");
...@@ -425,5 +450,124 @@ public class GrowRect extends GlowArrayElem { ...@@ -425,5 +450,124 @@ public class GrowRect extends GlowArrayElem {
} }
} }
public void get_borders( GlowTransform t, GlowGeometry g) {
double ll_x, ur_x, ll_y, ur_y, x1, x2, y1, y2;
if ( t != null) {
x1 = trf.x( t, ll.x, ll.y);
x2 = trf.x( t, ur.x, ur.y);
y1 = trf.y( t, ll.x, ll.y);
y2 = trf.y( t, ur.x, ur.y);
}
else {
x1 = trf.x( ll.x, ll.y);
x2 = trf.x( ur.x, ur.y);
y1 = trf.y( ll.x, ll.y);
y2 = trf.y( ur.x, ur.y);
}
ll_x = Math.min( x1, x2);
ur_x = Math.max( x1, x2);
ll_y = Math.min( y1, y2);
ur_y = Math.max( y1, y2);
if ( ll_x < g.ll_x)
g.ll_x = ll_x;
if ( ur_x > g.ur_x)
g.ur_x = ur_x;
if ( ll_y < g.ll_y)
g.ll_y = ll_y;
if ( ur_y > g.ur_y)
g.ur_y = ur_y;
}
public void get_node_borders() {
GlowGeometry g = new GlowGeometry();
g.ll_x = g.ll_y = 1e37;
g.ur_x = g.ur_y = -1e37;
get_borders( null, g);
x_left = g.ll_x;
x_right = g.ur_x;
y_low = g.ll_y;
y_high = g.ur_y;
}
} void set_scale( double scale_x, double scale_y,
double x0, double y0, int type) {
double old_x_left, old_x_right, old_y_low, old_y_high;
if ( trf.s_a11 != 0 && trf.s_a22 != 0 &&
Math.abs( scale_x - trf.a11 / trf.s_a11) < Float.MIN_VALUE &&
Math.abs( scale_y - trf.a22 / trf.s_a22) < Float.MIN_VALUE)
return;
switch( type) {
case Glow.eScaleType_LowerLeft:
x0 = x_left;
y0 = y_low;
break;
case Glow.eScaleType_LowerRight:
x0 = x_right;
y0 = y_low;
break;
case Glow.eScaleType_UpperRight:
x0 = x_right;
y0 = y_high;
break;
case Glow.eScaleType_UpperLeft:
x0 = x_left;
y0 = y_high;
break;
case Glow.eScaleType_FixPoint:
break;
case Glow.eScaleType_Center:
x0 = (x_left + x_right) / 2;
y0 = (y_low + y_high) /2;
break;
default:
;
}
old_x_left = x_left;
old_x_right = x_right;
old_y_low = y_low;
old_y_high = y_high;
trf.scale_from_stored( scale_x, scale_y, x0, y0);
get_node_borders();
switch( type) {
case Glow.eScaleType_LowerLeft:
x_left = old_x_left;
y_low = old_y_low;
break;
case Glow.eScaleType_LowerRight:
x_right = old_x_right;
y_low = old_y_low;
break;
case Glow.eScaleType_UpperRight:
x_right = old_x_right;
y_high = old_y_high;
break;
case Glow.eScaleType_UpperLeft:
x_left = old_x_left;
y_high = old_y_high;
break;
case Glow.eScaleType_FixPoint:
break;
case Glow.eScaleType_Center:
x0 = (x_left + x_right) / 2;
y0 = (y_low + y_high) /2;
break;
default:
;
}
cmn.ctx.draw( old_x_left * cmn.mw.zoom_factor_x - cmn.mw.offset_x - Glow.DRAW_MP,
old_y_low * cmn.mw.zoom_factor_y - cmn.mw.offset_y - Glow.DRAW_MP,
old_x_right * cmn.mw.zoom_factor_x - cmn.mw.offset_x + Glow.DRAW_MP,
old_y_high * cmn.mw.zoom_factor_y - cmn.mw.offset_y + Glow.DRAW_MP);
cmn.ctx.draw( x_left * cmn.mw.zoom_factor_x - cmn.mw.offset_x - Glow.DRAW_MP,
y_low * cmn.mw.zoom_factor_y - cmn.mw.offset_y - Glow.DRAW_MP,
x_right * cmn.mw.zoom_factor_x - cmn.mw.offset_x + Glow.DRAW_MP,
y_high * cmn.mw.zoom_factor_y - cmn.mw.offset_y + Glow.DRAW_MP);
}
}
\ No newline at end of file
/* /*
* Proview Open Source Process Control. * Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB. * Copyright (C) 2005-2012 SSAB EMEA AB.
* *
...@@ -185,7 +185,7 @@ public class GrowText extends GlowArrayElem { ...@@ -185,7 +185,7 @@ public class GrowText extends GlowArrayElem {
/* /*
GlowPoint rp; GlowPoint rp;
switch ( event.type) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
return 0; return 0;
default: ; default: ;
...@@ -193,8 +193,6 @@ public class GrowText extends GlowArrayElem { ...@@ -193,8 +193,6 @@ public class GrowText extends GlowArrayElem {
rp = trf.reverse( fx, fy); rp = trf.reverse( fx, fy);
System.out.println( "Event handler: " + fx + " " + fy + " reverse: " + rp.x + " " + rp.y);
System.out.println( " p: " + p.x + " " + p.y);
if ( ll.x <= rp.x && rp.x <= ur.x && if ( ll.x <= rp.x && rp.x <= ur.x &&
ll.y <= rp.y && rp.y <= ur.y) { ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in text"); System.out.println( "Event handler: Hit in text");
......
...@@ -4,16 +4,19 @@ local_java_sources := \ ...@@ -4,16 +4,19 @@ local_java_sources := \
Glow.java,\ Glow.java,\
PrintfFormat.java,\ PrintfFormat.java,\
GlowCFormat.java,\ GlowCFormat.java,\
GlowEvent.java,\ GlowFillLevelLimits.java,\
GlowGeometry.java,\
GlowPointX.java,\ GlowPointX.java,\
GlowDimension.java,\ GlowDimension.java,\
GlowMenuInfo.java,\
GrowApplIfc.java,\ GrowApplIfc.java,\
GlowColorRgb.java,\ GlowColorRgb.java,\
GlowColor.java,\ GlowColor.java,\
GlowDrawIfc.java,\ GlowDrawIfc.java,\
GlowDraw.java,\ GlowDraw.java,\
GrowNodeIfc.java,\
GlowArrayElem.java,\ GlowArrayElem.java,\
GlowEvent.java,\
GlowEventMenu.java,\
GrowCtxIfc.java,\ GrowCtxIfc.java,\
GrowCmn.java,\ GrowCmn.java,\
GlowTransform.java,\ GlowTransform.java,\
...@@ -30,6 +33,7 @@ local_java_sources := \ ...@@ -30,6 +33,7 @@ local_java_sources := \
GrowPolyline.java,\ GrowPolyline.java,\
GrowText.java,\ GrowText.java,\
GrowAnnot.java,\ GrowAnnot.java,\
GrowMenu.java,\
GlowVector.java,\ GlowVector.java,\
GrowCtx.java,\ GrowCtx.java,\
DynParsedAttrName.java,\ DynParsedAttrName.java,\
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment