Commit 82846444 authored by Claes Sjofors's avatar Claes Sjofors

jopg second commit

parent 1b8c2a17
......@@ -956,8 +956,8 @@ public class Dyn {
return;
GlowEvent e = new GlowEvent();
e.type = event;
e.object = object;
e.event = event;
e.object = (GlowArrayElem)object;
action_type1 &= ~mActionType1_Confirm;
for ( int i = 0; i < elements.size(); i++)
elements.get(i).action((GrowNode)object, e);
......@@ -1150,7 +1150,7 @@ public class Dyn {
return 0;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -1300,7 +1300,7 @@ public class Dyn {
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -1433,7 +1433,7 @@ public class Dyn {
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -1569,7 +1569,7 @@ public class Dyn {
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -1739,7 +1739,7 @@ public class Dyn {
}
else {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -1886,7 +1886,7 @@ public class Dyn {
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -2008,7 +2008,7 @@ public class Dyn {
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -2142,7 +2142,7 @@ public class Dyn {
return 1;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -2464,7 +2464,7 @@ public class Dyn {
if ( mainInstance != null) {
if ( !mainInstance.attrFound) {
DynParsedAttrName pname = dyn.parseAttrName(mainInstance.attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -2700,7 +2700,7 @@ public class Dyn {
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -2899,7 +2899,7 @@ public class Dyn {
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -3036,7 +3036,7 @@ public class Dyn {
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -4030,11 +4030,170 @@ public class Dyn {
double min_value;
String minvalue_attr;
String maxvalue_attr;
PwrtRefId subid;
int p;
int database;
boolean inverted;
boolean attrFound = false;
boolean firstScan = true;
int a_typeid;
float oldValue;
boolean limits_found = false;
double limit_min;
double limit_max;
int max_value_p;
int min_value_p;
PwrtRefId max_value_subid;
PwrtRefId min_value_subid;
public DynFillLevel( Dyn dyn) {
super(dyn, Dyn.mDynType1_FillLevel, 0, 0, 0);
}
public int connect(GrowNode object) {
color = dyn.getColor2(object, color);
if ( color < 0 || color >= Glow.eDrawType__)
return 0;
if ( attribute == null)
return 0;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
switch( pname.database) {
case GraphIfc.eDatabase_Gdh:
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
break;
default:
ret = null;
}
if ( ret == null || ret.evenSts()) {
System.out.println("FillLevel: " + attribute);
return 1;
}
p = ret.id;
subid = ret.refid;
inverted = pname.inverted;
a_typeid = pname.type;
attrFound = true;
if ( (dyn.total_dyn_type1 & Dyn.mDynType1_Tone) != 0) {
if ( color >= Glow.eDrawTone__)
object.setLevelFillColor(color);
else
object.setLevelColorTone(color);
}
else
object.setLevelFillColor(color);
GlowFillLevelLimits limits = object.getLimits();
if ( (limits.status & 1) != 0) {
limits_found = true;
limit_min = limits.min;
limit_max = limits.max;
direction = limits.direction;
}
object.setLevelDirection( direction);
min_value_p = 0;
pname = dyn.parseAttrName(minvalue_attr);
if ( pname != null && !pname.name.isEmpty() && pname.type == Pwr.eType_Float32 && database == GraphIfc.eDatabase_Gdh) {
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
if ( ret != null && ret.oddSts()) {
min_value_p = ret.id;
min_value_subid = ret.refid;
}
}
max_value_p = 0;
pname = dyn.parseAttrName(minvalue_attr);
if ( pname != null && !pname.name.isEmpty() && pname.type == Pwr.eType_Float32 && database == GraphIfc.eDatabase_Gdh) {
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
if ( ret != null && ret.oddSts()) {
max_value_p = ret.id;
max_value_subid = ret.refid;
}
}
return 1;
}
public void disconnect() {
if ( attrFound && database == GraphIfc.eDatabase_Gdh)
dyn.graph.getGdh().unrefObjectInfo(subid);
if ( min_value_p != 0)
dyn.graph.getGdh().unrefObjectInfo(min_value_subid);
if ( max_value_p != 0)
dyn.graph.getGdh().unrefObjectInfo(max_value_subid);
}
public void scan(GrowNode object) {
if ( !attrFound)
return;
float minval, maxval;
float pvalue = dyn.graph.getGdh().getObjectRefInfoFloat( p);
if ( max_value_p != 0 && min_value_p != 0) {
minval = dyn.graph.getGdh().getObjectRefInfoFloat( min_value_p);
maxval = dyn.graph.getGdh().getObjectRefInfoFloat( max_value_p);
if ( minval != min_value ||
maxval != max_value) {
min_value = minval;
max_value = maxval;
firstScan = true;
}
}
if ( !firstScan) {
if ( Math.abs( oldValue - pvalue) < Float.MIN_VALUE)
// No change since last time
return;
}
else
firstScan = false;
if ( max_value == min_value)
return;
double value = 0;
if ( !limits_found)
value = (pvalue - min_value) / (max_value - min_value);
else {
GlowGeometry geom = object.measure();
switch ( direction) {
case Glow.eDirection_Right:
value = ((pvalue - min_value) / (max_value - min_value) * ( limit_max - limit_min)
+ (limit_min - geom.ll_x)) / (geom.ur_x - geom.ll_x);
break;
case Glow.eDirection_Left:
value = ((pvalue - min_value) / (max_value - min_value) * ( limit_max - limit_min)
+ (geom.ur_x - limit_max)) / (geom.ur_x - geom.ll_x);
break;
case Glow.eDirection_Up:
value = ((pvalue - min_value) / (max_value - min_value) * ( limit_max - limit_min)
+ (limit_min - geom.ll_y)) / (geom.ur_y - geom.ll_y);
break;
case Glow.eDirection_Down:
value = ((pvalue - min_value) / (max_value - min_value) * ( limit_max - limit_min)
+ (geom.ur_y - limit_max)) / (geom.ur_y - geom.ll_y);
break;
default: ;
}
}
System.out.println("FillLevel: " + value);
object.setFillLevel( value);
oldValue = pvalue;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
......@@ -4095,11 +4254,80 @@ public class Dyn {
public class DynDigCommand extends DynElem {
String attribute;
String command;
PwrtRefId subid;
int p;
int database;
boolean inverted;
boolean attrFound = false;
boolean firstScan = true;
int bitmask;
int a_typeid;
boolean oldValue;
public DynDigCommand( Dyn dyn) {
super(dyn, Dyn.mDynType1_DigCommand, 0, 0, 0);
}
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
switch( pname.database) {
case GraphIfc.eDatabase_Gdh:
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
break;
case GraphIfc.eDatabase_Ccm:
// TODO
break;
default:
ret = null;
}
if ( ret == null || ret.evenSts()) {
System.out.println("DigLowColor: " + attribute);
return 1;
}
p = ret.id;
subid = ret.refid;
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
attrFound = true;
return 1;
}
public void disconnect() {
if ( attrFound && database == GraphIfc.eDatabase_Gdh)
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
if ( !attrFound)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
if ( inverted)
value = !value;
if ( !firstScan) {
if ( oldValue == value)
return;
}
else
firstScan = false;
System.out.println("DigCommand: value " + value);
if ( value && !oldValue) {
dyn.graph.command(command);
}
oldValue = value;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
......@@ -4199,7 +4427,7 @@ public class Dyn {
}
public int action( GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -4280,7 +4508,7 @@ public class Dyn {
}
public int action( GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -4361,7 +4589,7 @@ public class Dyn {
}
public int action( GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -4436,7 +4664,7 @@ public class Dyn {
}
public int action( GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down: {
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -4528,7 +4756,7 @@ public class Dyn {
}
public int action( GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -4592,7 +4820,7 @@ public class Dyn {
}
public int action( GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -4659,7 +4887,7 @@ public class Dyn {
if ( (dyn.action_type1 & Dyn.mActionType1_Confirm) == 0)
return 1;
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
break;
case Glow.eEvent_MB1Click:
......@@ -4718,7 +4946,7 @@ public class Dyn {
}
public int action(GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -4842,7 +5070,7 @@ public class Dyn {
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
......@@ -4902,7 +5130,7 @@ public class Dyn {
}
public int action(GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -5061,7 +5289,7 @@ public class Dyn {
}
public int action( GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -5136,7 +5364,7 @@ public class Dyn {
}
public int action( GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -5223,7 +5451,7 @@ public class Dyn {
}
public int action( GrowNode object, GlowEvent e) {
switch ( e.type) {
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
......@@ -5499,6 +5727,35 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_PulldownMenu, 0);
}
public int action( GrowNode object, GlowEvent e) {
/*
switch ( e.event) {
case Glow.eEvent_MB1Click:
break;
case Glow.eEvent_MenuActivated:
if ( menu_object == null)
break;
if ( e.object == menu_object) {
if ( items_dyn[e.item] != null) {
GlowEvent event;
event.event = Glow.eEvent_MB1Click;
return items_dyn[event.item].action( e.object, event);
}
}
else {
for ( int j = 0; j < 32; j++) {
if ( items_dyn[j] != null &&
items_dyn[j].action_type1 & Dyn.mActionType1_PulldownMenu != 0)
items_dyn[j].action( null, e);
}
}
break;
default: ;
}
*/
return 1;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
......@@ -5800,11 +6057,311 @@ public class Dyn {
int button_mask;
String[] items_text = new String[32];
int[] items_enum = new int[32];
PwrtRefId subid;
int p;
int database;
boolean inverted;
boolean attrFound = false;
boolean firstScan = true;
int bitmask;
int a_typeid;
float oldValueF;
int oldValueI;
PwrtRefId update_subid;
int update_p;
int update_database;
boolean update_inverted;
boolean update_attrFound = false;
int update_bitmask;
int update_a_typeid;
boolean update_oldValue;
GrowMenu menu_object;
int text_size;
public DynOptionMenu( Dyn dyn) {
super(dyn, 0, 0, Dyn.mActionType1_OptionMenu, 0);
}
public int connect(GrowNode object) {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
return 1;
GdhrRefObjectInfo ret = null;
switch( pname.database) {
case GraphIfc.eDatabase_Gdh:
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
break;
case GraphIfc.eDatabase_Local:
ret = dyn.graph.getLdb().refObjectInfo( graph, pname.name);
break;
default:
ret = null;
}
if ( ret == null || ret.evenSts()) {
System.out.println("OptionMenu: " + attribute);
return 1;
}
p = ret.id;
subid = ret.refid;
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
attrFound = true;
if ( text_attribute != null && !text_attribute.isEmpty() &&
update_attribute != null && !update_attribute.isEmpty()) {
pname = dyn.parseAttrName(update_attribute);
if ( pname != null && !pname.name.isEmpty()) {
ret = null;
switch( pname.database) {
case GraphIfc.eDatabase_Gdh:
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
break;
default:
ret = null;
}
if ( ret == null || ret.evenSts()) {
System.out.println("OptionsMenu: " + update_attribute);
return 1;
}
update_p = ret.id;
update_subid = ret.refid;
update_inverted = pname.inverted;
update_a_typeid = pname.type;
update_bitmask = pname.bitmask;
update_database = pname.database;
}
}
return 1;
}
public void disconnect() {
if ( attrFound && database == GraphIfc.eDatabase_Gdh)
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
if ( !attrFound)
return;
boolean update_texts = false;
if ( update_p != 0) {
boolean value = dyn.getDig(p, update_a_typeid, update_bitmask, update_database);
if (update_inverted)
value = !value;
if ( !firstScan) {
if ( update_oldValue != value)
update_texts = true;
}
else {
firstScan = false;
update_texts = false;
}
update_oldValue = value;
}
if ( update_texts) {
}
int enum_value = 0;
switch ( a_typeid) {
case Pwr.eType_Float32: {
float value = dyn.graph.getGdh().getObjectRefInfoFloat( p);
int i;
if ( !firstScan) {
if ( value == oldValueF) {
return;
}
}
else
firstScan = false;
enum_value = (int)( value + 0.5);
oldValueF = value;
break;
}
case Pwr.eType_UInt32:
case Pwr.eType_Int32: {
int value = dyn.graph.getGdh().getObjectRefInfoInt( p);
int i;
if ( !firstScan) {
if ( value == oldValueI) {
return;
}
}
else
firstScan = false;
enum_value = value;
oldValueI = value;
break;
}
default:
return;
}
if ( update_p == 0) {
boolean found = false;
for ( int i = 0; i < 32; i++) {
if ( items_enum[i] == enum_value) {
object.setAnnotation(1, items_text[i]);
found = true;
break;
}
}
if ( !found)
object.setAnnotation(1, "");
}
else {
}
}
public int action( GrowNode object, GlowEvent e) {
switch ( e.event) {
case Glow.eEvent_MB1Click:
if ( menu_object != null) {
// Close, delete this menu
System.out.println("Remove menu" + menu_object);
dyn.graph.getCtx().remove(menu_object);
menu_object = null;
}
else {
double ll_x, ll_y, ur_x, ur_y;
GlowMenuInfo info = new GlowMenuInfo();
if ( update_p == 0) {
int b_mask = 1;
for ( int i = 0; i < 32; i++) {
if ( (b_mask & button_mask) != 0) {
info.item[i].occupied = true;
info.item[i].text = new String(items_text[i]);
// Check access
info.item[i].type = Glow.eMenuItem_Button;
}
else
info.item[i].occupied = false;
b_mask = b_mask << 1;
}
}
else {
for ( int i = 0; i < 32; i++) {
if ( i < text_size) {
info.item[i].text = new String(items_text[i]);
info.item[i].type = Glow.eMenuItem_Button;
info.item[i].occupied = true;
}
else
info.item[i].occupied = false;
}
}
// Get fillcolor, and textattributes from object
int text_drawtype = 4, text_color = Glow.eDrawType_Line, bg_color = Glow.eDrawType_Color32;
int tsize = 2;
int sts;
double scale = 1;
int text_font = Glow.eFont_Helvetica;
sts = 0; //grow_GetObjectAnnotInfo( object, 1, &tsize, &text_drawtype, &text_color, &bg_color, &scale, &text_font);
if ( (sts & 1) == 0) {
tsize = 2;
text_drawtype = Glow.eDrawType_TextHelveticaBold;
text_color = Glow.eDrawType_Line;
bg_color = Glow.eDrawType_LightGray;
}
else if ( bg_color == Glow.eDrawType_No || bg_color == Glow.eDrawType_Inherit)
bg_color = Glow.eDrawType_LightGray;
GlowGeometry g = object.measure();
menu_object = new GrowMenu( dyn.graph.getCtx().cmn, "__Menu", info, g.ll_x, g.ur_y, g.ur_x - g.ll_x,
Glow.eDrawType_Line, 0, 1, 1, bg_color, tsize,
text_drawtype, text_color,
Glow.eDrawType_MediumGray, text_font);
menu_object.set_scale( scale, scale, 0, 0, Glow.eScaleType_LowerLeft);
System.out.println("Insert menu" + menu_object);
dyn.graph.getCtx().insert(menu_object);
}
break;
case Glow.eEvent_MenuActivated:
if ( menu_object == null)
break;
if ( e.object == menu_object) {
// Set enum value to attribute
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
return 1;
PwrtStatus sts = null;
switch ( pname.database) {
case GraphIfc.eDatabase_Gdh:
switch ( pname.type) {
case Pwr.eType_Float32: {
float value = items_enum[((GlowEventMenu)e).item];
sts = dyn.graph.getGdh().setObjectInfo( pname.name, value);
break;
}
case Pwr.eType_Int32:
case Pwr.eType_UInt32:
case Pwr.eType_Int16:
case Pwr.eType_UInt16:
case Pwr.eType_Int8:
case Pwr.eType_UInt8: {
int value = items_enum[((GlowEventMenu)e).item];
sts = dyn.graph.getGdh().setObjectInfo( pname.name, value);
break;
}
default: ;
}
break;
case GraphIfc.eDatabase_Ccm: {
/* TODO
pwr_tInt32 value = items_enum[event->menu.item];
sts = dyn->graph->ccm_set_variable( parsed_name, type_id, &value);
*/
break;
}
default : ;
}
if ( sts == null || sts.evenSts()) System.out.println("Option menu error: " + pname.name);
}
break;
case Glow.eEvent_MenuDelete:
if ( menu_object == null)
break;
if ( e.object == null || e.object == menu_object) {
// Delete this menu
dyn.graph.getCtx().remove(menu_object);
menu_object = null;
}
break;
default: ;
}
return 1;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
......@@ -6091,6 +6648,10 @@ public class Dyn {
dyn_type1 = Dyn.mDynType1_AnalogText;
}
public int action( GrowNode object, GlowEvent e) {
return 1;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
......
......@@ -39,7 +39,8 @@ package jpwr.jopg;
public class Glow {
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_TYPE_SIZE = 9;
......@@ -1466,10 +1467,16 @@ public class Glow {
public static final int ePosition_Absolute = 0;
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_MB1Up = 2;
public static final int eEvent_MB1Down = 3;
public static final int eEvent_MB1DoubleClick = 4;
public static final int eEvent_CursorMotion = 5;
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 {
public void draw() {}
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 Object getUserData() { return null;}
}
......@@ -461,4 +461,13 @@ public class GlowDraw implements GlowDrawIfc {
}
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 {
public int gradient_rotate(double rotate, int gradient);
public GlowDimension getTextExtent( String text, int idx, int 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.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
......@@ -37,10 +37,12 @@
package jpwr.jopg;
public class GlowEvent {
public int event;
public int type;
public double x;
public double y;
Object object;
public GlowArrayElem object;
public int object_type;
public GlowEvent() {}
}
\ No newline at end of file
}
......@@ -49,6 +49,10 @@ public class GlowPoint {
this.cmn = cmn;
}
public void posit(double x, double y) {
this.x = x;
this.y = y;
}
public void open(BufferedReader reader) {
String line;
StringTokenizer token;
......
......@@ -57,6 +57,10 @@ public class GlowTransform {
boolean stored;
public GlowTransform() {
a11 = 1;
a22 = 1;
s_a11 = 1;
s_a22 = 1;
}
public void store() {
......
......@@ -38,6 +38,7 @@
package jpwr.jopg;
import jpwr.rt.*;
import java.io.*;
import java.util.*;
public class Graph implements GraphIfc, GrowApplIfc {
public static final int eType_Bit = (1 << 15) + 1;
......@@ -61,6 +62,12 @@ public class Graph implements GraphIfc, GrowApplIfc {
cmn.setGdraw(gdraw);
}
public int getWidth() {
return appl.getWidth();
}
public int getHeight() {
return appl.getHeight();
}
public Gdh getGdh() {
return gdh;
}
......@@ -158,6 +165,9 @@ public class Graph implements GraphIfc, GrowApplIfc {
}
public DynParsedAttrName parseAttrName( String name) {
if ( name == null)
return null;
int idx, tidx, eidx;
DynParsedAttrName pname = new DynParsedAttrName();
......@@ -222,10 +232,74 @@ public class Graph implements GraphIfc, GrowApplIfc {
}
public void eventHandler(GlowEvent e) {
if ( e.object != null) {
int sts;
Dyn dyn = (Dyn)((GrowNode)e.object).getUserData();
sts = dyn.action((GrowNode)e.object, e);
switch ( e.event) {
case Glow.eEvent_MB1Click:
if ( e.object_type == Glow.eObjectType_NoObject ||
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;
public interface GraphApplIfc {
public int command(String cmd);
public void openConfirmDialog( Object dyn, String text, Object object);
public int getWidth();
public int getHeight();
}
......@@ -43,4 +43,6 @@ public interface GrowApplIfc {
public void traceDisconnect(GrowNode object);
public void traceScan(GrowNode object);
public void eventHandler(GlowEvent e);
public int getWidth();
public int getHeight();
}
......@@ -241,7 +241,7 @@ public class GrowArc extends GlowArrayElem {
public int eventHandler( GlowEvent event, double fx, double fy) {
GlowPoint rp;
switch ( event.type) {
switch ( event.event) {
case Glow.eEvent_CursorMotion:
return 0;
default: ;
......@@ -251,8 +251,6 @@ public class GrowArc extends GlowArrayElem {
//rp = new GlowPoint(null);
//rp.x = fx;
//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 &&
ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in arc");
......
......@@ -49,6 +49,10 @@ public class GrowCmn {
public double base_zoom_factor;
public int offset_x;
public int offset_y;
public int window_width;
public int window_height;
public int subwindow_x;
public int subwindow_y;
}
public GrowApplIfc appl;
......@@ -96,6 +100,9 @@ public class GrowCmn {
int hot_indication;
Object userdata;
GlowArrayElem callback_object;
int callback_object_type;
int hot_mode;
int hot_found;
Vector<GlowArrayElem> a = new Vector<GlowArrayElem>();
Vector<GlowArrayElem> a_nc = new Vector<GlowArrayElem>();
......@@ -106,8 +113,16 @@ public class GrowCmn {
this.appl = appl;
this.debug = 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) {
this.gdraw = gdraw;
}
......
......@@ -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_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) {
int sts = 0;
cmn.callback_object = null;
cmn.callback_object_type = Glow.eObjectType_NoObject;
for ( int i = cmn.a.size() - 1; i >= 0; i--) {
sts = ((GlowArrayElem)cmn.a.get(i)).eventHandler(e, e.x, e.y);
if ( sts == 1) {
......@@ -364,6 +385,7 @@ public class GrowCtx implements GrowCtxIfc {
if ( sts == 1 && cmn.appl != null) {
e.object = cmn.callback_object;
e.object_type = cmn.callback_object_type;
cmn.appl.eventHandler(e);
}
}
......@@ -446,6 +468,18 @@ public class GrowCtx implements GrowCtxIfc {
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 @@
*/
package jpwr.jopg;
import java.util.*;
public interface GrowCtxIfc {
......@@ -42,5 +43,11 @@ public interface GrowCtxIfc {
public GlowArrayElem get_object_group( GlowArrayElem object);
public void draw();
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 {
setSize();
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
setDefaultCloseOperation( DISPOSE_ON_CLOSE);
localPanel.addMouseListener(new MouseAdapter() {
MouseAdapter adapter = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("MouseListener");
GlowEvent event = new GlowEvent();
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.type = Glow.eEvent_MB1Click;
event.event = Glow.eEvent_MB1Click;
graph.ctx.eventHandler( event);
}
public void mousePressed(MouseEvent e) {
......@@ -144,7 +144,7 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
GlowEvent event = new GlowEvent();
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.type = Glow.eEvent_MB1Down;
event.event = Glow.eEvent_MB1Down;
graph.ctx.eventHandler( event);
}
public void mouseReleased(MouseEvent e) {
......@@ -152,23 +152,33 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
GlowEvent event = new GlowEvent();
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.type = Glow.eEvent_MB1Up;
event.event = Glow.eEvent_MB1Up;
graph.ctx.eventHandler( event);
}
public void mouseMoved(MouseEvent e) {
System.out.println("MouseListener");
GlowEvent event = new GlowEvent();
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.type = Glow.eEvent_CursorMotion;
event.event = Glow.eEvent_CursorMotion;
graph.ctx.eventHandler( event);
}
});
};
localPanel.addMouseListener(adapter);
localPanel.addMouseMotionListener(adapter);
timer = new Timer( scanTime, this);
timer.start();
}
public int getWidth() {
return localPanel.getWidth();
}
public int getHeight() {
return localPanel.getHeight();
}
public void actionPerformed( ActionEvent e) {
scanCount++;
if ( scanCount == 1)
......
......@@ -181,15 +181,13 @@ public class GrowLine extends GlowArrayElem {
/*
GlowPoint rp;
switch ( event.type) {
switch ( event.event) {
case Glow.eEvent_CursorMotion:
return 0;
default: ;
}
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 &&
ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in rect");
......
......@@ -93,6 +93,9 @@ public class GrowNode extends GlowArrayElem {
public int input_selected;
public int annotv_inputmode[] = new int[10];
public double fill_level = 1;
public int level_fill_drawtype;
public int level_color_tone;
public int level_direction;
GrowCmn cmn;
......@@ -343,7 +346,7 @@ public class GrowNode extends GlowArrayElem {
GlowPoint rp;
int sts;
switch ( event.type) {
switch ( event.event) {
case Glow.eEvent_CursorMotion:
return 0;
default: ;
......@@ -354,12 +357,10 @@ public class GrowNode extends GlowArrayElem {
if ( sts != 0) {
System.out.println( "Hit in node " + sts);
if ( type() != Glow.eObjectType_GrowGroup)
cmn.ctx.register_callback_object(this);
cmn.ctx.register_callback_object(Glow.eObjectType_Node, this);
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 &&
ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in rect");
......@@ -372,7 +373,8 @@ public class GrowNode extends GlowArrayElem {
public void draw() {
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) {
......@@ -396,7 +398,145 @@ public class GrowNode extends GlowArrayElem {
else
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() {
......@@ -444,6 +584,18 @@ public class GrowNode extends GlowArrayElem {
public void setColorInverse(int 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) {
return annotv[number];
}
......@@ -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_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 {
/*
GlowPoint rp;
switch ( event.type) {
switch ( event.event) {
case Glow.eEvent_CursorMotion:
return 0;
default: ;
......@@ -266,8 +266,6 @@ public class GrowPolyline extends GlowArrayElem {
//rp = new GlowPoint(null);
//rp.x = fx;
//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 &&
ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in polyline");
......
......@@ -78,6 +78,33 @@ public class GrowRect extends GlowArrayElem {
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() {
return Glow.eObjectType_GrowRect;
}
......@@ -240,7 +267,7 @@ public class GrowRect extends GlowArrayElem {
public int eventHandler( GlowEvent event, double fx, double fy) {
GlowPoint rp;
switch ( event.type) {
switch ( event.event) {
case Glow.eEvent_CursorMotion:
return 0;
default: ;
......@@ -250,8 +277,6 @@ public class GrowRect extends GlowArrayElem {
//rp = new GlowPoint(null);
//rp.x = fx;
//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 &&
ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in rect");
......@@ -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.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
......@@ -185,7 +185,7 @@ public class GrowText extends GlowArrayElem {
/*
GlowPoint rp;
switch ( event.type) {
switch ( event.event) {
case Glow.eEvent_CursorMotion:
return 0;
default: ;
......@@ -193,8 +193,6 @@ public class GrowText extends GlowArrayElem {
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 &&
ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in text");
......
......@@ -4,16 +4,19 @@ local_java_sources := \
Glow.java,\
PrintfFormat.java,\
GlowCFormat.java,\
GlowEvent.java,\
GlowFillLevelLimits.java,\
GlowGeometry.java,\
GlowPointX.java,\
GlowDimension.java,\
GlowMenuInfo.java,\
GrowApplIfc.java,\
GlowColorRgb.java,\
GlowColor.java,\
GlowDrawIfc.java,\
GlowDraw.java,\
GrowNodeIfc.java,\
GlowArrayElem.java,\
GlowEvent.java,\
GlowEventMenu.java,\
GrowCtxIfc.java,\
GrowCmn.java,\
GlowTransform.java,\
......@@ -30,6 +33,7 @@ local_java_sources := \
GrowPolyline.java,\
GrowText.java,\
GrowAnnot.java,\
GrowMenu.java,\
GlowVector.java,\
GrowCtx.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