Commit 0201bd6b authored by Claes Sjofors's avatar Claes Sjofors

jopg third commit

parent 2fe7f512
......@@ -197,32 +197,45 @@ public class JopSessionRep implements JopSessionIfc {
if ( gcret.value > 0)
suffix = Integer.toString(gcret.value);
}
if ( coid.objid.vid < Cdh.cUserClassVolMin ||
(coid.objid.vid >= Cdh.cManufactClassVolMin &&
coid.objid.vid <= Cdh.cManufactClassVolMax)) {
// Class is a base class, java classname starts with JopC
if ( coid.objid.vid == 1)
name = "jpwr.jopc.Jopc" + sret.str.substring(1,2).toUpperCase() +
sret.str.substring(2).toLowerCase() + suffix;
else if ( coid.objid.vid == 64002)
name = "jpwr.abb.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix;
else if ( coid.objid.vid == 10) {
if ( sret.str.startsWith( "BaseFcPPO"))
name = "jpwr.bcompfc.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix;
name = "pwr_c_" + sret.str.toLowerCase() + ".pwg"; // Pwg test
int pwgidx = name.lastIndexOf( ".pwg");
if ( pwgidx == -1) {
if ( coid.objid.vid < Cdh.cUserClassVolMin ||
(coid.objid.vid >= Cdh.cManufactClassVolMin &&
coid.objid.vid <= Cdh.cManufactClassVolMax)) {
// Class is a base class, java classname starts with JopC
if ( coid.objid.vid == 1)
name = "jpwr.jopc.Jopc" + sret.str.substring(1,2).toUpperCase() +
sret.str.substring(2).toLowerCase() + suffix;
else if ( coid.objid.vid == 64002)
name = "jpwr.abb.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix;
else if ( coid.objid.vid == 10) {
if ( sret.str.startsWith( "BaseFcPPO"))
name = "jpwr.bcompfc.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix;
else
name = "jpwr.bcomp.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix;
}
else
name = "jpwr.jopc.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix;
}
else
name = "jpwr.bcomp.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix;
}
else
name = "jpwr.jopc.Jopc" + sret.str.substring(0,1).toUpperCase() +
sret.str.substring(1).toLowerCase() + suffix;
// Java name equals class name
name = sret.str.substring(0,1).toUpperCase() + sret.str.substring(1).toLowerCase() +
suffix;
}
else {
if ( coid.objid.vid < Cdh.cUserClassVolMin ||
(coid.objid.vid >= Cdh.cManufactClassVolMin &&
coid.objid.vid <= Cdh.cManufactClassVolMax)) {
name = "$pwr_exe/" + name;
}
if ( suffix.length() > 0)
name = name.substring(0, pwgidx) + suffix + name.substring(pwgidx+1);
}
else
// Java name equals class name
name = sret.str.substring(0,1).toUpperCase() + sret.str.substring(1).toLowerCase() +
suffix;
JopLog.log("openGraphFrame classgraph " + name);
Object graph;
......
......@@ -45,6 +45,7 @@ import java.applet.*;
import java.util.*;
import jpwr.rt.*;
import java.awt.event.*;
import jpwr.jopg.*;
public class JopSpider {
int qcom_qix;
......@@ -59,6 +60,20 @@ public class JopSpider {
static String methObject;
static PwrtAttrRef methAref;
static int methClassId;
static JopSpider spider;
private static class GrowFrameCb implements GrowFrameApplIfc {
JopSession session;
GrowFrameCb( JopSession session) {
this.session = session;
}
public int command( String cmd) {
System.out.println("JopSpider command callback : " + cmd);
return JopSpider.command( session, cmd);
}
}
public JopSpider( int op_qcom_qix) {
JopSpider.op_qcom_qix = op_qcom_qix;
......@@ -760,44 +775,53 @@ System.out.println( "JopSpiderCmd start");
public static Object loadFrame( JopSession session, String className,
String instance, boolean scrollbar) throws ClassNotFoundException {
Object frame;
if ( instance == null)
instance = "";
if ( className.indexOf(".pwg") != -1) {
GrowFrame frame = new GrowFrame(className, session.getGdh(), instance, new GrowFrameCb(session));
frame.validate();
frame.setVisible(true);
}
else {
Object frame;
if ( instance == null)
instance = "";
JopLog.log("JopSpider.loadFrame: Loading frame \"" + className + "\" instance \"" + instance + "\"");
try {
Class clazz = Class.forName( className);
try {
Class argTypeList[] = new Class[] { session.getClass(), instance.getClass(),
boolean.class};
Object argList[] = new Object[] { session, instance, new Boolean(scrollbar)};
System.out.println( "JopSpider.loadFrame getConstructor");
Constructor constructor = clazz.getConstructor( argTypeList);
try {
frame = constructor.newInstance( argList);
}
catch ( Exception e) {
System.out.println("Class instanciation error: " + className + " " + e.getMessage() + " " + constructor);
JopLog.log("JopSpider.loadFrame: Loading frame \"" + className + "\" instance \"" + instance + "\"");
try {
Class clazz = Class.forName( className);
try {
Class argTypeList[] = new Class[] { session.getClass(), instance.getClass(),
boolean.class};
Object argList[] = new Object[] { session, instance, new Boolean(scrollbar)};
System.out.println( "JopSpider.loadFrame getConstructor");
Constructor constructor = clazz.getConstructor( argTypeList);
try {
frame = constructor.newInstance( argList);
}
catch ( Exception e) {
System.out.println("Class instanciation error: " + className + " " + e.getMessage() + " " + constructor);
return null;
}
// frame = clazz.newInstance();
JopLog.log( "JopSpider.loadFrame openFrame");
openFrame( frame);
return frame;
}
catch ( NoSuchMethodException e) {
System.out.println("NoSuchMethodException: Unable to get frame constructor " + className);
}
catch ( Exception e) {
System.out.println("Exception: Unable to get frame class " + className + " " + e.getMessage());
}
}
catch (ClassNotFoundException e) {
System.out.println("Class not found: " + className);
throw new ClassNotFoundException();
}
return null;
}
// frame = clazz.newInstance();
JopLog.log( "JopSpider.loadFrame openFrame");
openFrame( frame);
return frame;
}
catch ( NoSuchMethodException e) {
System.out.println("NoSuchMethodException: Unable to get frame constructor " + className);
}
catch ( Exception e) {
System.out.println("Exception: Unable to get frame class " + className + " " + e.getMessage());
}
}
catch (ClassNotFoundException e) {
System.out.println("Class not found: " + className);
throw new ClassNotFoundException();
}
return null;
return null;
}
public static void openFrame( Object frame) {
......@@ -1027,6 +1051,7 @@ System.out.println( "JopSpiderCmd start");
}
return null;
}
}
......
......@@ -887,7 +887,7 @@ public class Dyn {
return graph.parseAttrName( name);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem object) {
if ( (dyn_type1 & Dyn.mDynType1_Inherit) != 0) {
int inherit_dyn_type1 = object.getClassDynType1();
......@@ -927,7 +927,7 @@ public class Dyn {
}
}
public void scan(GrowNode object) {
public void scan(GlowArrayElem object) {
repaintNow = false;
ignoreColor = false;
resetColor = false;
......@@ -939,9 +939,9 @@ public class Dyn {
object.draw();
}
int action(GrowNode object, GlowEvent event) {
int action(GlowArrayElem object, GlowEvent event) {
int sts;
System.out.println("Dyn Action " + event.event + " object " + event.object);
for ( int i = 0; i < elements.size(); i++) {
sts = elements.get(i).action(object, event);
if ( sts == Dyn.DYN__NO_PROPAGATE || sts == Glow.GLOW__TERMINATED ||
......@@ -960,7 +960,7 @@ public class Dyn {
e.object = (GlowArrayElem)object;
action_type1 &= ~mActionType1_Confirm;
for ( int i = 0; i < elements.size(); i++)
elements.get(i).action((GrowNode)object, e);
elements.get(i).action((GlowArrayElem)object, e);
action_type1 |= mActionType1_Confirm;
}
......@@ -983,10 +983,10 @@ public class Dyn {
}
public int getDynType1() {return dyn_type1;}
public void open( BufferedReader reader) {}
public int connect(GrowNode object) {return 0;}
public int connect(GlowArrayElem object) {return 0;}
public void disconnect() {}
public void scan(GrowNode object) {}
public int action(GrowNode object, GlowEvent event) {return 0;}
public void scan(GlowArrayElem object) {}
public int action(GlowArrayElem object, GlowEvent event) {return 0;}
}
public class DynDigLowColor extends DynElem {
......@@ -1006,7 +1006,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_DigLowColor, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
color = dyn.getColor1(object, color);
if ( color < 0 || color >= Glow.eDrawType__)
return 0;
......@@ -1014,6 +1015,7 @@ public class Dyn {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.isEmpty())
return 1;
System.out.println("DigLowColor: " + attribute + " pname " + pname.name + " db " + pname.database);
GdhrRefObjectInfo ret = null;
......@@ -1038,17 +1040,19 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
public void disconnect() {
if ( attrFound && database != GraphIfc.eDatabase_Local)
if ( attrFound && database == GraphIfc.eDatabase_Gdh)
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound || dyn.ignoreColor)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
......@@ -1144,7 +1148,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_DigColor, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
color = dyn.getColor2(object, color);
if ( color < 0 || color >= Glow.eDrawType__)
return 0;
......@@ -1173,17 +1178,19 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
public void disconnect() {
if ( attrFound && database != GraphIfc.eDatabase_Local)
if ( attrFound && database == GraphIfc.eDatabase_Gdh)
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound || dyn.ignoreColor)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
......@@ -1298,7 +1305,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_DigWarning, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
return 1;
......@@ -1323,17 +1331,19 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
public void disconnect() {
if ( attrFound && database != GraphIfc.eDatabase_Local)
if ( attrFound && database == GraphIfc.eDatabase_Gdh)
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound || dyn.ignoreColor)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
......@@ -1431,7 +1441,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_DigError, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
return 1;
......@@ -1456,6 +1467,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
......@@ -1466,7 +1478,8 @@ public class Dyn {
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound || dyn.ignoreColor)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
......@@ -1567,7 +1580,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_DigFlash, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
return 1;
......@@ -1592,6 +1606,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
......@@ -1602,7 +1617,8 @@ public class Dyn {
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound || dyn.ignoreColor)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
......@@ -1732,10 +1748,16 @@ public class Dyn {
super(dyn, Dyn.mDynType1_Invisible, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( attribute.toLowerCase().startsWith("$cmd(")) {
cmd = true;
command = attribute.substring(5, attribute.length()-1);
int idx = attribute.lastIndexOf(')');
if ( idx != -1 && idx > 5)
command = attribute.substring(5, idx);
else
command = attribute.substring(5);
command = graph.getCommand(command);
}
else {
DynParsedAttrName pname = dyn.parseAttrName(attribute);
......@@ -1765,6 +1787,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
}
return 1;
......@@ -1775,10 +1798,11 @@ public class Dyn {
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( cmd) {
if ( firstScan) {
int sts = 0; // TODO Jop.executeCommand( dyn.session, command);
int sts = dyn.graph.command(command);
System.out.println( "DynInvisible: " + command + ", value: " + sts);
if ( sts == 0) {
if ( dimmed == 0)
......@@ -1795,6 +1819,9 @@ public class Dyn {
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
if ( a_typeid == Pwr.eType_String)
value = !value;
if ( inverted)
value = !value;
......@@ -1837,7 +1864,7 @@ public class Dyn {
break;
case Dyn.eSave_Invisible_attribute:
if ( token.hasMoreTokens())
attribute = token.nextToken();
attribute = line.substring(4);
break;
case Dyn.eSave_Invisible_dimmed:
dimmed = new Integer(token.nextToken()).intValue();
......@@ -1884,7 +1911,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_DigBorder, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
return 1;
......@@ -1909,6 +1937,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
......@@ -1919,7 +1948,8 @@ public class Dyn {
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
......@@ -2005,7 +2035,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_DigText, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
......@@ -2031,6 +2062,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
high_text = object.getAnnotation(1);
if ( high_text == null)
......@@ -2043,7 +2075,8 @@ public class Dyn {
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
......@@ -2137,7 +2170,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_Value, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( format == null)
return 1;
......@@ -2168,6 +2202,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
......@@ -2177,7 +2212,8 @@ public class Dyn {
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
......@@ -2257,7 +2293,7 @@ public class Dyn {
break;
}
if ( firstScan || value0.compareTo( oldValueS) != 0) {
if ( firstScan || !value0.equals( oldValueS)) {
sb = cFormat.format( value0, sb);
object.setAnnotation(1, new String(sb));
dyn.repaintNow = true;
......@@ -2451,7 +2487,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_AnalogColor, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
// Find the main instance
DynAnalogColor mainInstance = null;
for ( int i = dyn.elements.size() - 1; i >= 0; i--) {
......@@ -2505,7 +2542,8 @@ public class Dyn {
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound || dyn.ignoreColor)
return;
......@@ -2697,7 +2735,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_Rotate, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
......@@ -2723,6 +2762,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
if ( x0 != 0 || y0 != 0)
......@@ -2739,7 +2779,8 @@ public class Dyn {
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
float value0 = dyn.graph.getGdh().getObjectRefInfoFloat( p);
......@@ -2896,7 +2937,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_AnalogShift, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
......@@ -2925,6 +2967,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
......@@ -2935,7 +2978,8 @@ public class Dyn {
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
......@@ -3033,7 +3077,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_DigShift, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
......@@ -3062,6 +3107,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
......@@ -3072,7 +3118,8 @@ public class Dyn {
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
......@@ -3224,11 +3271,145 @@ public class Dyn {
String attribute;
String minvalue_attr;
String maxvalue_attr;
float maxval;
float minval;
PwrtRefId subid;
int p;
int database;
boolean inverted;
boolean attrFound = false;
boolean firstScan = true;
int a_typeid;
float old_value;
int old_ivalue;
int max_value_p;
int min_value_p;
PwrtRefId max_value_subid;
PwrtRefId min_value_subid;
float old_max_value;
float old_min_value;
public DynBar( Dyn dyn) {
super(dyn, Dyn.mDynType1_Bar, 0, 0, 0);
}
public int connect(GlowArrayElem o) {
GrowBar object = (GrowBar)o;
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("Bar: " + attribute);
return 1;
}
p = ret.id;
subid = ret.refid;
inverted = pname.inverted;
a_typeid = pname.type;
attrFound = true;
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(maxvalue_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( GlowArrayElem o) {
GrowBar object = (GrowBar)o;
if ( !attrFound)
return;
float minval, maxval;
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 != old_min_value ||
maxval != old_max_value) {
System.out.println("Bar set range min : " + minval + " max : " + maxval);
object.set_range(minval, maxval);
old_min_value = minval;
old_max_value = maxval;
}
}
switch (a_typeid) {
case Pwr.eType_Float32: {
float value = dyn.graph.getGdh().getObjectRefInfoFloat( p);
if ( !firstScan) {
if ( Math.abs( old_value - value) < Float.MIN_VALUE)
// No change since last time
return;
}
else
firstScan = false;
object.set_value(value);
old_value = value;
break;
}
case Pwr.eType_Int32:
case Pwr.eType_UInt32: {
int value = dyn.graph.getGdh().getObjectRefInfoInt( p);
if ( !firstScan) {
if ( old_ivalue == value)
// No change since last time
return;
}
else
firstScan = false;
object.set_value(value);
old_ivalue = value;
break;
}
}
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
......@@ -3281,11 +3462,236 @@ public class Dyn {
String maxvalue_attr1;
String minvalue_attr2;
String maxvalue_attr2;
int p1;
int database1;
boolean inverted1;
int a_typeid1;
PwrtRefId subid1;
int p2;
int database2;
boolean inverted2;
int a_typeid2;
PwrtRefId subid2;
boolean attrFound = false;
boolean firstScan = true;
int max_value1_p;
int min_value1_p;
PwrtRefId max_value1_subid;
PwrtRefId min_value1_subid;
float old_max_value1;
float old_min_value1;
int max_value2_p;
int min_value2_p;
PwrtRefId max_value2_subid;
PwrtRefId min_value2_subid;
float old_max_value2;
float old_min_value2;
double scan_time;
double acc_time;
int trend_hold;
public DynTrend( Dyn dyn) {
super(dyn, Dyn.mDynType1_Trend, 0, 0, 0);
}
public int connect(GlowArrayElem o) {
GrowTrend object = (GrowTrend)o;
if ( attribute1 == null)
return 0;
DynParsedAttrName pname = dyn.parseAttrName(attribute1);
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("Trend: " + attribute1);
return 1;
}
p1 = ret.id;
subid1 = ret.refid;
inverted1 = pname.inverted;
a_typeid1 = pname.type;
attrFound = true;
pname = dyn.parseAttrName(attribute2);
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("Trend: " + attribute2);
return 1;
}
else {
p2 = ret.id;
subid2 = ret.refid;
inverted2 = pname.inverted;
a_typeid2 = pname.type;
}
}
scan_time = object.get_scan_time();
acc_time = scan_time;
trend_hold = 0;
min_value1_p = 0;
pname = dyn.parseAttrName(minvalue_attr1);
if ( pname != null && !pname.name.isEmpty() && pname.type == Pwr.eType_Float32 && pname.database == GraphIfc.eDatabase_Gdh) {
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
if ( ret != null && ret.oddSts()) {
min_value1_p = ret.id;
min_value1_subid = ret.refid;
}
}
max_value1_p = 0;
pname = dyn.parseAttrName(maxvalue_attr1);
if ( pname != null && !pname.name.isEmpty() && pname.type == Pwr.eType_Float32 && pname.database == GraphIfc.eDatabase_Gdh) {
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
if ( ret != null && ret.oddSts()) {
max_value1_p = ret.id;
max_value1_subid = ret.refid;
}
}
min_value2_p = 0;
pname = dyn.parseAttrName(minvalue_attr2);
if ( pname != null && !pname.name.isEmpty() && pname.type == Pwr.eType_Float32 && pname.database == GraphIfc.eDatabase_Gdh) {
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
if ( ret != null && ret.oddSts()) {
min_value2_p = ret.id;
min_value2_subid = ret.refid;
}
}
max_value2_p = 0;
pname = dyn.parseAttrName(maxvalue_attr2);
if ( pname != null && !pname.name.isEmpty() && pname.type == Pwr.eType_Float32 && pname.database == GraphIfc.eDatabase_Gdh) {
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
if ( ret != null && ret.oddSts()) {
max_value2_p = ret.id;
max_value2_subid = ret.refid;
}
}
return 1;
}
public void disconnect() {
if ( attrFound && database1 == GraphIfc.eDatabase_Gdh)
dyn.graph.getGdh().unrefObjectInfo(subid1);
if ( p2 != 0 && database2 == GraphIfc.eDatabase_Gdh)
dyn.graph.getGdh().unrefObjectInfo(subid2);
if ( min_value1_p != 0)
dyn.graph.getGdh().unrefObjectInfo(min_value1_subid);
if ( max_value1_p != 0)
dyn.graph.getGdh().unrefObjectInfo(max_value1_subid);
if ( min_value2_p != 0)
dyn.graph.getGdh().unrefObjectInfo(min_value2_subid);
if ( max_value2_p != 0)
dyn.graph.getGdh().unrefObjectInfo(max_value2_subid);
}
public void scan( GlowArrayElem o) {
GrowTrend object = (GrowTrend)o;
if ( !attrFound)
return;
float minval, maxval;
if ( max_value1_p != 0 && min_value1_p != 0) {
minval = dyn.graph.getGdh().getObjectRefInfoFloat( min_value1_p);
maxval = dyn.graph.getGdh().getObjectRefInfoFloat( max_value1_p);
if ( minval != old_min_value1 ||
maxval != old_max_value1) {
object.set_range_y(0, minval, maxval);
old_min_value1 = minval;
old_max_value1 = maxval;
}
}
if ( firstScan)
firstScan = false;
acc_time += dyn.graph.getScanTime();
if ( acc_time + Double.MIN_VALUE >= scan_time) {
if ( p1 != 0) {
switch ( a_typeid1) {
case Pwr.eType_Boolean: {
boolean value = dyn.graph.getGdh().getObjectRefInfoBoolean( p1);
if ( value)
object.add_value(1, 0);
else
object.add_value(0, 0);
break;
}
case Pwr.eType_Float32: {
float value = dyn.graph.getGdh().getObjectRefInfoFloat( p1);
object.add_value((double)value, 0);
break;
}
case Pwr.eType_Int32:
case Pwr.eType_UInt32: {
int value = dyn.graph.getGdh().getObjectRefInfoInt( p1);
object.add_value((double)value, 0);
break;
}
default: ;
}
}
if ( p2 != 0) {
switch ( a_typeid2) {
case Pwr.eType_Boolean: {
boolean value = dyn.graph.getGdh().getObjectRefInfoBoolean( p2);
if ( value)
object.add_value(1, 1);
else
object.add_value(0, 1);
break;
}
case Pwr.eType_Float32: {
float value = dyn.graph.getGdh().getObjectRefInfoFloat( p2);
object.add_value((double)value, 1);
break;
}
case Pwr.eType_Int32:
case Pwr.eType_UInt32: {
int value = dyn.graph.getGdh().getObjectRefInfoInt( p2);
object.add_value((double)value, 1);
break;
}
default: ;
}
}
}
acc_time = 0;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
......@@ -4050,7 +4456,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_FillLevel, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
color = dyn.getColor2(object, color);
if ( color < 0 || color >= Glow.eDrawType__)
return 0;
......@@ -4113,7 +4520,7 @@ public class Dyn {
}
max_value_p = 0;
pname = dyn.parseAttrName(minvalue_attr);
pname = dyn.parseAttrName(maxvalue_attr);
if ( pname != null && !pname.name.isEmpty() && pname.type == Pwr.eType_Float32 && database == GraphIfc.eDatabase_Gdh) {
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
......@@ -4135,7 +4542,8 @@ public class Dyn {
dyn.graph.getGdh().unrefObjectInfo(max_value_subid);
}
public void scan(GrowNode object) {
public void scan(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
......@@ -4268,7 +4676,8 @@ public class Dyn {
super(dyn, Dyn.mDynType1_DigCommand, 0, 0, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
......@@ -4297,7 +4706,9 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
......@@ -4307,7 +4718,8 @@ public class Dyn {
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
......@@ -4323,7 +4735,9 @@ public class Dyn {
firstScan = false;
System.out.println("DigCommand: value " + value);
if ( value && !oldValue) {
dyn.graph.command(command);
String cmd = graph.getCommand(command);
dyn.graph.command(cmd);
}
oldValue = value;
}
......@@ -4348,7 +4762,7 @@ public class Dyn {
break;
case Dyn.eSave_DigCommand_command:
if ( token.hasMoreTokens())
command = token.nextToken();
command = line.substring(5);
break;
case Dyn.eSave_DigCommand_instance:
instance = new Integer(token.nextToken()).intValue();
......@@ -4426,7 +4840,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_SetDig, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -4507,7 +4922,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_ResetDig, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -4588,7 +5004,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_ToggleDig, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -4663,7 +5080,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_StoDig, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down: {
object.setColorInverse( 1);
......@@ -4755,7 +5173,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_Command, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -4769,7 +5188,9 @@ public class Dyn {
if ( (dyn.action_type1 & Dyn.mActionType1_Confirm) != 0)
break;
dyn.graph.command(command);
String cmd = graph.getCommand(command);
dyn.graph.command(cmd);
break;
}
return 1;
......@@ -4803,8 +5224,7 @@ public class Dyn {
if ( end_found)
break;
}
}
} catch ( Exception e) {
System.out.println( "IOException DynCommand");
}
......@@ -4819,7 +5239,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_CommandDoubleClick, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -4833,7 +5254,9 @@ public class Dyn {
if ( (dyn.action_type1 & Dyn.mActionType1_Confirm) != 0)
break;
dyn.graph.command(command);
String cmd = graph.getCommand(command);
dyn.graph.command(cmd);
break;
}
return 1;
......@@ -4855,7 +5278,7 @@ public class Dyn {
break;
case Dyn.eSave_CommandDC_command:
if ( token.hasMoreTokens())
command = token.nextToken();
command = line.substring(5);
break;
case Dyn.eSave_End:
end_found = true;
......@@ -4883,7 +5306,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_Confirm, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
if ( (dyn.action_type1 & Dyn.mActionType1_Confirm) == 0)
return 1;
......@@ -4945,7 +5369,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_IncrAnalog, 0);
}
public int action(GrowNode object, GlowEvent e) {
public int action(GrowNode o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -5067,7 +5492,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_RadioButton, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
......@@ -5096,6 +5522,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
return 1;
}
......@@ -5106,7 +5533,8 @@ public class Dyn {
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
boolean value = dyn.getDig(p, a_typeid, bitmask, database);
......@@ -5129,7 +5557,8 @@ public class Dyn {
oldValue = value;
}
public int action(GrowNode object, GlowEvent e) {
public int action(GrowNode o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -5150,9 +5579,9 @@ public class Dyn {
Vector<GlowArrayElem> list = group.get_object_list();
for ( int i = 0; i < list.size(); i++) {
GlowArrayElem o = list.get(i);
if ( o != e.object &&
o.type() == Glow.eObjectType_GrowNode) {
GlowArrayElem oe = list.get(i);
if ( oe != e.object &&
oe.type() == Glow.eObjectType_GrowNode) {
value = false;
Dyn gm_dyn = (Dyn)((GrowNode)o).getUserData();
......@@ -5288,7 +5717,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_Help, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -5363,7 +5793,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_OpenGraph, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -5450,7 +5881,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_OpenURL, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -5612,11 +6044,432 @@ public class Dyn {
String minvalue_attr;
String maxvalue_attr;
String insensitive_attr;
PwrtRefId subid;
int p;
int database;
boolean inverted;
boolean attrFound = false;
float old_value;
int old_ivalue;
boolean firstScan = true;
int bitmask;
int a_typeid;
int max_value_p;
PwrtRefId max_value_subid;
int min_value_p;
PwrtRefId min_value_subid;
int insensitive_p;
PwrtRefId insensitive_subid;
int insensitive_db;
boolean insensitive_inverted;
float min_value;
float max_value;
float old_min_value;
float old_max_value;
boolean slider_disabled = true;
int direction;
public DynSlider( Dyn dyn) {
super(dyn, 0, 0, Dyn.mActionType1_Slider, 0);
}
public int connect(GlowArrayElem o) {
GrowSlider object = (GrowSlider)o;
System.out.println("Slider connect");
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("Slider: " + attribute);
return 1;
}
p = ret.id;
subid = ret.refid;
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
// Get min and max position from slider background
double max_value, min_value, max_pos, min_pos;
Object background;
double origo;
if ( !object.transformIsStored()) {
object.storeTransform();
GlowGeometry g = object.measure();
System.out.println("Slider measure: (" + g.ll_x + "," + g.ll_y + ") (" + g.ur_x + "," + g.ur_y + ")");
GlowSliderInfo info = ((GrowSlider)object).get_info();
GlowBackgroundObject b = dyn.graph.getCtx().getBackgroundObjectLimits(Dyn.mDynType1_SliderBackground,
(g.ll_x + g.ur_x) / 2, (g.ll_y + g.ur_y) / 2);
System.out.println("Slider background sts: " + b.sts + " direction " + b.direction);
if ( (b.sts & 1) != 0) {
direction = b.direction;
origo = ((GrowSlider)object).get_origo(info.direction);
switch( direction) {
case Glow.eDirection_Down:
info.max_position = b.max - origo;
info.min_position = b.min - origo;
((GrowSlider)object).set_info(info);
object.move_to(g.ll_x, info.min_position);
break;
case Glow.eDirection_Up:
info.max_position = b.max - (g.ur_y - g.ll_y - origo);
info.min_position = b.min - (g.ur_y - g.ll_y - origo);
((GrowSlider)object).set_info(info);
object.move_to(g.ll_x, info.min_position);
break;
case Glow.eDirection_Left:
info.max_position = b.max - (g.ur_x - g.ll_x - origo);
info.min_position = b.min - (g.ur_x - g.ll_x - origo);
((GrowSlider)object).set_info(info);
object.move_to(info.min_position, g.ll_y);
break;
case Glow.eDirection_Right:
info.max_position = b.max - origo;
info.min_position = b.min - origo;
((GrowSlider)object).set_info(info);
object.move_to(info.min_position, g.ll_y);
break;
default:
;
}
}
else
direction = info.direction;
object.storeTransform();
}
max_value_p = 0;
pname = dyn.parseAttrName(maxvalue_attr);
if ( pname != null && !pname.name.isEmpty() && pname.type == Pwr.eType_Float32 ) {
ret = null;
switch( pname.database) {
case GraphIfc.eDatabase_Gdh:
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
break;
default:
ret = null;
}
if ( ret != null) {
max_value_p = ret.id;
max_value_subid = ret.refid;
}
}
min_value_p = 0;
pname = dyn.parseAttrName(minvalue_attr);
if ( pname != null && !pname.name.isEmpty() && pname.type == Pwr.eType_Float32 ) {
ret = null;
switch( pname.database) {
case GraphIfc.eDatabase_Gdh:
ret = dyn.graph.getGdh().refObjectInfo( pname.name);
break;
default:
ret = null;
}
if ( ret != null) {
min_value_p = ret.id;
min_value_subid = ret.refid;
}
}
insensitive_p = 0;
pname = dyn.parseAttrName(insensitive_attr);
System.out.println("Slider insensitive " + pname.name + " type : " + pname.type);
if ( pname != null && !pname.name.isEmpty() && pname.type == Pwr.eType_Boolean) {
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);
System.out.println("Slider insensitive " + pname.name + " ret : " + ret);
break;
default:
ret = null;
}
if ( ret != null) {
insensitive_p = ret.id;
insensitive_subid = ret.refid;
insensitive_inverted = pname.inverted;
insensitive_db = pname.database;
}
}
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);
if ( insensitive_p != 0 && insensitive_db == GraphIfc.eDatabase_Gdh)
dyn.graph.getGdh().unrefObjectInfo(insensitive_subid);
}
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
float value = 0;
int ivalue = 0;
switch ( a_typeid) {
case Pwr.eType_Float32:
value = dyn.graph.getGdh().getObjectRefInfoFloat( p);
break;
case Pwr.eType_Int32:
ivalue = dyn.graph.getGdh().getObjectRefInfoInt( p);
break;
case Pwr.eType_Boolean: {
boolean b;
b = dyn.graph.getGdh().getObjectRefInfoBoolean( p);
ivalue = b ? 1 : 0;
break;
}
}
if ( insensitive_p != 0) {
switch ( insensitive_db) {
case GraphIfc.eDatabase_Gdh:
slider_disabled = dyn.graph.getGdh().getObjectRefInfoBoolean( insensitive_p);
break;
case GraphIfc.eDatabase_Local:
slider_disabled = dyn.graph.getLdb().getObjectRefInfoBoolean( insensitive_p);
break;
}
if ( insensitive_inverted)
slider_disabled = !slider_disabled;
}
else
slider_disabled = false;
if ( max_value_p != 0 && min_value_p != 0) {
max_value = dyn.graph.getGdh().getObjectRefInfoFloat( max_value_p);
min_value = dyn.graph.getGdh().getObjectRefInfoFloat( min_value_p);
if ( max_value != old_max_value ||
min_value != old_min_value) {
if ( Math.abs( max_value - min_value) > Double.MIN_VALUE)
firstScan = true;
}
old_min_value = min_value;
old_max_value = max_value;
}
if ( !firstScan) {
switch ( a_typeid) {
case Pwr.eType_Float32:
if ( Math.abs( old_value - value) < Double.MIN_VALUE)
// No change since last time
return;
break;
case Pwr.eType_Int32:
case Pwr.eType_Boolean:
if ( ivalue == old_ivalue)
return;
break;
default: ;
}
}
else
firstScan = false;
switch ( a_typeid) {
case Pwr.eType_Float32:
old_value = value;
break;
case Pwr.eType_Int32:
case Pwr.eType_Boolean:
old_ivalue = ivalue;
break;
default: ;
}
GlowSliderInfo info = ((GrowSlider)object).get_info();
System.out.println("info.min_pos " + info.min_position + " max_pos " + info.max_position);
if ( !(max_value_p != 0 && min_value_p != 0 && max_value != min_value)) {
max_value = (float)info.max_value;
min_value = (float)info.min_value;
}
if ( info.min_position != info.max_position) {
if ( dyn.graph.getCurrentSlider() != object &&
max_value != min_value) {
double pos_x, pos_y;
switch ( a_typeid) {
case Pwr.eType_Float32:
break;
default:
value = (float) (ivalue);
break;
}
switch ( direction) {
case Glow.eDirection_Down:
pos_y = (max_value - value) / (max_value - min_value) *
(info.max_position - info.min_position);
if ( pos_y < 0)
pos_y = 0;
else if ( pos_y > info.max_position - info.min_position)
pos_y = info.max_position - info.min_position;
pos_x = 0;
break;
case Glow.eDirection_Right:
pos_x = info.max_position - info.min_position -
(value - min_value) / (max_value - min_value) *
(info.max_position - info.min_position);
if ( pos_x < 0)
pos_x = 0;
else if ( pos_x > info.max_position - info.min_position)
pos_x = info.max_position - info.min_position;
pos_y = 0;
break;
case Glow.eDirection_Left:
pos_x = info.max_position - info.min_position -
(max_value - value) / (max_value - min_value) *
(info.max_position - info.min_position);
if ( pos_x < 0)
pos_x = 0;
else if ( pos_x > info.max_position - info.min_position)
pos_x = info.max_position - info.min_position;
pos_y = 0;
break;
default: // Up
pos_y = (value - min_value) / (max_value - min_value) *
(info.max_position - info.min_position);
if ( pos_y < 0)
pos_y = 0;
else if ( pos_y > info.max_position - info.min_position)
pos_y = info.max_position - info.min_position;
pos_x = 0;
}
System.out.println("Slider ivalue " + ivalue + " pos_y " + pos_y);
object.set_position(pos_x, pos_y);
}
}
}
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
if ( slider_disabled)
return 1;
switch ( e.event) {
case Glow.eEvent_SliderMoveStart: {
if ( !dyn.graph.isAuthorized( dyn.access) ||
slider_disabled) {
dyn.graph.getCtx().setMoveRestrictions(Glow.eMoveRestriction_Disable, 0, 0, null);
dyn.graph.setCurrentSlider(null);
break;
}
GlowSliderInfo info = ((GrowSlider)object).get_info();
System.out.println("Slider start direction " + info.direction);
if ( direction == Glow.eDirection_Right ||
direction == Glow.eDirection_Left)
dyn.graph.getCtx().setMoveRestrictions( Glow.eMoveRestriction_HorizontalSlider,
info.max_position, info.min_position, e.object);
else
dyn.graph.getCtx().setMoveRestrictions( Glow.eMoveRestriction_VerticalSlider,
info.max_position, info.min_position, e.object);
dyn.graph.setCurrentSlider((GrowSlider)object);
break;
}
case Glow.eEvent_SliderMoveEnd: {
if ( dyn.graph.getCurrentSlider() == object)
dyn.graph.setCurrentSlider(null);
break;
}
case Glow.eEvent_SliderMoved: {
float value;
GlowSliderInfo info = ((GrowSlider)object).get_info();
if ( info.min_position != info.max_position) {
if ( !(max_value_p != 0 && min_value_p != 0 && max_value != min_value)) {
max_value = (float)info.max_value;
min_value = (float)info.min_value;
}
GlowGeometry g = object.measure();
switch ( direction) {
case Glow.eDirection_Down:
value = (float)( (info.max_position - g.ll_y) / (info.max_position - info.min_position) *
(max_value - min_value) + min_value);
break;
case Glow.eDirection_Right:
value = (float)( (info.max_position - g.ll_x) / (info.max_position - info.min_position) *
(max_value - min_value) + min_value);
break;
case Glow.eDirection_Left:
value = (float)( (g.ll_x - info.min_position) / (info.max_position - info.min_position) *
(max_value - min_value) + min_value);
break;
default:
value = (float)( (g.ll_y - info.min_position) / (info.max_position - info.min_position) *
(max_value - min_value) + min_value);
}
System.out.println("Slider value " + value + " minpos " + info.min_position + " maxpos " + info.max_position);
if ( value > max_value)
value = max_value;
if ( value < min_value)
value = min_value;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
return 1;
PwrtStatus sts;
switch ( pname.type) {
case Pwr.eType_Float32:
sts = dyn.graph.getGdh().setObjectInfo( pname.name, value);
break;
case Pwr.eType_Boolean: {
boolean bvalue = (value > 0.5 ? true : false);
sts = dyn.graph.getGdh().setObjectInfo( pname.name, bvalue);
break;
}
default: {
int ivalue = (int) (value > 0 ? value + 0.5 : value - 0.5);
sts = dyn.graph.getGdh().setObjectInfo( pname.name, ivalue);
}
}
if ( sts.evenSts()) System.out.println("Slider error: " + attribute);
}
break;
}
default: ;
}
return 1;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
......@@ -5727,7 +6580,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_PulldownMenu, 0);
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
/*
switch ( e.event) {
case Glow.eEvent_MB1Click:
......@@ -6082,7 +6936,8 @@ public class Dyn {
super(dyn, 0, 0, Dyn.mActionType1_OptionMenu, 0);
}
public int connect(GrowNode object) {
public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o;
DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.isEmpty())
......@@ -6111,6 +6966,7 @@ public class Dyn {
inverted = pname.inverted;
a_typeid = pname.type;
bitmask = pname.bitmask;
database = pname.database;
attrFound = true;
if ( text_attribute != null && !text_attribute.isEmpty() &&
......@@ -6149,7 +7005,8 @@ public class Dyn {
dyn.graph.getGdh().unrefObjectInfo(subid);
}
public void scan( GrowNode object) {
public void scan( GlowArrayElem o) {
GrowNode object = (GrowNode)o;
if ( !attrFound)
return;
......@@ -6234,7 +7091,8 @@ public class Dyn {
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Click:
if ( menu_object != null) {
......@@ -6648,7 +7506,7 @@ public class Dyn {
dyn_type1 = Dyn.mDynType1_AnalogText;
}
public int action( GrowNode object, GlowEvent e) {
public int action( GlowArrayElem o, GlowEvent e) {
return 1;
}
......
......@@ -45,6 +45,9 @@ public class Glow {
public static final int DRAW_MP = 6;
public static final int DRAW_TYPE_SIZE = 9;
public static final int DRAW_FONT_SIZE = 9;
public static final int DRAWOFFSET = 2;
public static final int TREND_MAX_CURVES = 11;
public static final int eType_Boolean = 0;
public static final int eType_Int = 1;
public static final int eType_Double = 2;
......@@ -803,6 +806,7 @@ public class Glow {
public static final int eSave_NodeClass_userdata_cb = 329;
public static final int eSave_NodeClass_dyn_type2 = 330;
public static final int eSave_NodeClass_dyn_action_type2 = 331;
public static final int eSave_NodeClass_recursive_trace = 332;
public static final int eSave_ConClass_cc_name = 400;
public static final int eSave_ConClass_con_type = 401;
public static final int eSave_ConClass_corner = 402;
......@@ -1008,6 +1012,7 @@ public class Glow {
public static final int eSave_GrowCtx_bitmap_fonts = 2245;
public static final int eSave_GrowCtx_dyn_type2 = 2246;
public static final int eSave_GrowCtx_dyn_action_type2 = 2247;
public static final int eSave_GrowCtx_recursive_trace = 2248;
public static final int eSave_GrowSubAnnot_x_right = 2300;
public static final int eSave_GrowSubAnnot_x_left = 2301;
public static final int eSave_GrowSubAnnot_y_high = 2302;
......@@ -1467,6 +1472,10 @@ public class Glow {
public static final int ePosition_Absolute = 0;
public static final int ePosition_Relative = 1;
public static final int eMoveRestriction_VerticalSlider = 0;
public static final int eMoveRestriction_HorizontalSlider = 1;
public static final int eMoveRestriction_Disable = 2;
public static final int eEventType_Object = 0;
public static final int eEventType_Menu = 1;
......@@ -1475,8 +1484,12 @@ public class Glow {
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_ButtonMotion = 6;
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;
public static final int eEvent_SliderMoveStart = 11;
public static final int eEvent_SliderMoved = 12;
public static final int eEvent_SliderMoveEnd = 13;
}
......@@ -44,4 +44,11 @@ public class GlowArrayElem {
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;}
public void get_borders( GlowTransform t, GlowGeometry g) {}
public int get_background_object_limits(GlowTransform t, int type, double x, double y, GlowBackgroundObject b) {return 0;}
public int getClassDynType1() { return 0;}
public int getClassDynType2() { return 0;}
public int getClassActionType1() { return 0;}
public int getClassActionType2() { return 0;}
public int getClassCycle() { return 0;}
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
package jpwr.jopg;
public class GlowBackgroundObject {
public GlowArrayElem background;
public int direction;
public double max;
public double min;
public int sts;
}
\ No newline at end of file
......@@ -46,7 +46,7 @@ import java.awt.event.*;
public class GlowDraw implements GlowDrawIfc {
Graphics2D g2;
boolean nodraw;
boolean nodraw = true;
Font fonts[] = new Font[9];
......@@ -56,6 +56,7 @@ public class GlowDraw implements GlowDrawIfc {
public void setGraphics( Graphics2D g2) {
this.g2 = g2;
nodraw = false;
}
public void rect(int border, int fill, double x, double y, double width, double height) {
......@@ -244,6 +245,8 @@ public class GlowDraw implements GlowDrawIfc {
public void text( int x, int y, String text, int gc_type, int color, int idx, int highlight, int line,
int font_idx, double size, int rot) {
if ( nodraw)
return;
Color c = getColor(color);
......
......@@ -64,6 +64,7 @@ public class GlowNodeClass extends GlowArrayElem {
String[] dyn_attr = new String[4];
GlowArrayElem next_nc;
GlowArrayElem prev_nc;
int recursive_trace;
public GlowNodeClass(GrowCmn cmn) {
this.cmn = cmn;
......@@ -168,6 +169,9 @@ public class GlowNodeClass extends GlowArrayElem {
case Glow.eSave_NodeClass_input_focus_mark:
input_focus_mark = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_NodeClass_recursive_trace:
recursive_trace = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_NodeClass_dynamicsize:
dynamicsize = new Integer(token.nextToken()).intValue();
break;
......@@ -215,8 +219,9 @@ public class GlowNodeClass extends GlowArrayElem {
}
public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {
for ( int i = 0; i < a.size(); i++)
for ( int i = 0; i < a.size(); i++) {
a.get(i).draw(t, highlight, hot, node, colornode);
}
}
public int eventHandler( GlowEvent event, double fx, double fy) {
......@@ -229,4 +234,55 @@ public class GlowNodeClass extends GlowArrayElem {
}
return 0;
}
public void get_borders( GlowTransform t, GlowGeometry g) {
GlowNodeClass base = get_base_nc();
if ( (t == null || ( t != null && Math.abs( t.rotation/90 - (int)(t.rotation/90)) < Double.MIN_VALUE)) &&
!(Math.abs( base.x0 - base.x1) < Double.MIN_VALUE ||
Math.abs( base.y0 - base.y1) < Double.MIN_VALUE)) {
// Borders are given i x0, y0, x1, y1
// Will not work in rotated nodes
double ll_x, ur_x, ll_y, ur_y, kx1, kx2, ky1, ky2;
if ( t != null) {
kx1 = t.x( base.x0, base.y0);
kx2 = t.x( base.x1, base.y1);
ky1 = t.y( base.x0, base.y0);
ky2 = t.y( base.x1, base.y1);
}
else {
kx1 = base.x0;
kx2 = base.x1;
ky1 = base.y0;
ky2 = base.y1;
}
ll_x = Math.min( kx1, kx2);
ur_x = Math.max( kx1, kx2);
ll_y = Math.min( ky1, ky2);
ur_y = Math.max( ky1, ky2);
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;
}
else {
for ( int i = 0; i < a.size(); i++)
a.get(i).get_borders(t, g);
}
}
GlowNodeClass get_base_nc() {
GlowNodeClass base;
for ( base = this; base.prev_nc != null; base = (GlowNodeClass)base.prev_nc)
;
return base;
}
}
......@@ -49,6 +49,12 @@ public class GlowPoint {
this.cmn = cmn;
}
public GlowPoint(GlowPoint p) {
cmn = p.cmn;
x = p.x;
y = p.y;
}
public void posit(double x, double y) {
this.x = x;
this.y = y;
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
package jpwr.jopg;
public class GlowSliderInfo {
public int direction;
public double max_value;
public double min_value;
public double max_position;
public double min_position;
}
\ No newline at end of file
......@@ -83,7 +83,7 @@ public class GlowTransform {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
// if ( cmn.debug) System.out.println( "GlowTransform : " + line);
if ( true) System.out.println( "GlowTransform : " + line);
switch ( key) {
case Glow.eSave_Transform: break;
......@@ -287,4 +287,8 @@ public class GlowTransform {
return Math.sqrt( tmp.a12*tmp.a12 + tmp.a22*tmp.a22);
}
public boolean is_stored() {
return stored;
}
}
\ No newline at end of file
......@@ -84,6 +84,12 @@ public class GlowVector {
a.add( n);
break;
}
case Glow.eSave_GrowSlider: {
GrowSlider n = new GrowSlider( cmn);
n.open( reader);
a.add( n);
break;
}
case Glow.eSave_GrowGroup: {
GrowGroup n = new GrowGroup( cmn);
n.open( reader);
......@@ -132,6 +138,18 @@ public class GlowVector {
a.add( c);
break;
}
case Glow.eSave_GrowBar: {
GrowBar c = new GrowBar( cmn);
c.open( reader);
a.add( c);
break;
}
case Glow.eSave_GrowTrend: {
GrowTrend c = new GrowTrend( cmn);
c.open( reader);
a.add( c);
break;
}
case Glow.eSave_Point: {
GlowPoint c = new GlowPoint( cmn);
c.open( reader);
......
......@@ -50,6 +50,8 @@ public class Graph implements GraphIfc, GrowApplIfc {
public GraphApplIfc appl;
public Gdh gdh;
public GraphLocalDb ldb;
public GrowSlider currentSlider;
public double scan_time = 1;
public Graph(GraphApplIfc appl, Gdh gdh) {
this.appl = appl;
......@@ -83,19 +85,22 @@ public class Graph implements GraphIfc, GrowApplIfc {
ctx.traceConnect();
}
public void traceConnect(GrowNode object) {
public void traceConnect(GlowArrayElem object) {
Dyn dyn = (Dyn)object.getUserData();
dyn.connect(object);
if ( dyn != null)
dyn.connect(object);
}
public void traceDisconnect(GrowNode object) {
public void traceDisconnect(GlowArrayElem object) {
Dyn dyn = (Dyn)object.getUserData();
dyn.disconnect();
if ( dyn != null)
dyn.disconnect();
}
public void traceScan(GrowNode object) {
public void traceScan(GlowArrayElem object) {
Dyn dyn = (Dyn)object.getUserData();
dyn.scan(object);
if ( dyn != null)
dyn.scan(object);
}
int stringToType( String str) {
......@@ -141,6 +146,8 @@ public class Graph implements GraphIfc, GrowApplIfc {
return Pwr.eType_Mask;
if ( str.equalsIgnoreCase("bit"))
return Graph.eType_Bit;
if ( str.substring(0,6).equalsIgnoreCase("string"))
return Pwr.eType_String;
return 0;
}
......@@ -172,7 +179,72 @@ public class Graph implements GraphIfc, GrowApplIfc {
DynParsedAttrName pname = new DynParsedAttrName();
String str = name.trim();
if ( (idx = str.indexOf("$local.")) != -1) {
if ( (tidx = str.indexOf('#')) == -1)
pname.name = str.substring(idx+1);
else {
pname.name = str.substring(idx+7, tidx);
String type = str.substring(tidx);
if ( type.equals("##Float32"))
pname.type = Pwr.eType_Float32;
else if ( type.equals("##Float64"))
pname.type = Pwr.eType_Float64;
else if ( type.equals("##Int32"))
pname.type = Pwr.eType_Int32;
else if ( type.equals("##Boolean"))
pname.type = Pwr.eType_Boolean;
else
pname.type = Pwr.eType_String;
}
if ( str.startsWith("!")) {
str = str.substring(1);
str = str.trim();
pname.inverted = true;
}
else
pname.inverted = false;
pname.database = GraphIfc.eDatabase_Local;
return pname;
}
if ( (idx = str.indexOf("$ccm.")) != -1) {
if ( (tidx = str.indexOf('#')) == -1)
pname.name = str.substring(idx+1);
else {
pname.name = str.substring(idx+5, tidx);
String type = str.substring(tidx);
if ( type.equals("##Float32"))
pname.type = Pwr.eType_Float32;
else if ( type.equals("##Int32"))
pname.type = Pwr.eType_Int32;
else if ( type.equals("##Boolean"))
pname.type = Pwr.eType_Boolean;
else
pname.type = Pwr.eType_String;
}
if ( str.startsWith("!")) {
str = str.substring(1);
str = str.trim();
pname.inverted = true;
}
else
pname.inverted = false;
pname.database = GraphIfc.eDatabase_Ccm;
return pname;
}
if ( (idx = str.indexOf("$object")) != -1) {
if ( appl != null) {
String oname = appl.getObject();
str = str.substring(0, idx) + oname + str.substring(idx+7);
System.out.println("Parse name $object " + oname + " str " + str);
}
}
if ( (idx = str.indexOf('[')) != -1 &&
(eidx = str.lastIndexOf('#')) != -1 &&
str.charAt(eidx-1) != '#') {
......@@ -212,6 +284,19 @@ public class Graph implements GraphIfc, GrowApplIfc {
return pname;
}
public String getCommand(String cmd) {
String str = new String(cmd);
int idx;
while ( (idx = str.indexOf("$object")) != -1) {
if ( appl != null) {
String oname = appl.getObject();
str = str.substring(0, idx) + oname + str.substring(idx+7);
}
}
return str;
}
public Object growUserdataOpen( BufferedReader reader, Object object, int type) {
switch ( type) {
......@@ -264,6 +349,9 @@ public class Graph implements GraphIfc, GrowApplIfc {
case Glow.eEvent_MB1Up:
case Glow.eEvent_MB1Down:
case Glow.eEvent_ValueChanged:
case Glow.eEvent_SliderMoveStart:
case Glow.eEvent_SliderMoveEnd:
case Glow.eEvent_SliderMoved:
if ( e.object != null) {
int sts;
Dyn dyn = (Dyn)((GlowArrayElem)e.object).getUserData();
......@@ -317,4 +405,19 @@ public class Graph implements GraphIfc, GrowApplIfc {
// TODO
return null;
}
public GrowSlider getCurrentSlider() {
return currentSlider;
}
public void setCurrentSlider(GrowSlider currentSlider) {
this.currentSlider = currentSlider;
}
public boolean isAuthorized(int access) {
return true;
}
public double getScanTime() {
return scan_time;
}
}
......@@ -41,4 +41,5 @@ public interface GraphApplIfc {
public void openConfirmDialog( Object dyn, String text, Object object);
public int getWidth();
public int getHeight();
public String getObject();
}
......@@ -51,4 +51,9 @@ public interface GraphIfc {
public int command(String cmd);
public void openConfirmDialog(Object dyn, String text, Object object);
public String get_reference_name(String name);
public Object getCurrentSlider();
public void setCurrentSlider(GrowSlider currentSlider);
public boolean isAuthorized(int access);
public double getScanTime();
public String getCommand(String cmd);
}
......@@ -158,6 +158,8 @@ public class GrowAnnot extends GlowArrayElem {
public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {
int x1, y1;
if ( cmn.nodraw != 0)
return;
if ( ((GrowNode)node).annotv[number] == null)
return;
......
......@@ -39,9 +39,9 @@ import java.io.*;
public interface GrowApplIfc {
public Object growUserdataOpen( BufferedReader reader, Object object, int type);
public void traceConnect(GrowNode object);
public void traceDisconnect(GrowNode object);
public void traceScan(GrowNode object);
public void traceConnect(GlowArrayElem object);
public void traceDisconnect(GlowArrayElem object);
public void traceScan(GlowArrayElem object);
public void eventHandler(GlowEvent e);
public int getWidth();
public int getHeight();
......
......@@ -98,7 +98,8 @@ public class GrowArc extends GlowArrayElem {
case Glow.eSave_GrowArc:
break;
case Glow.eSave_GrowArc_n_name:
n_name = token.nextToken();
if ( token.hasMoreTokens())
n_name = token.nextToken();
break;
case Glow.eSave_GrowArc_x_right:
x_right = new Double(token.nextToken()).doubleValue();
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
package jpwr.jopg;
import jpwr.rt.*;
import java.io.*;
import java.util.*;
public class GrowBar extends GrowRect {
class TraceData{
String[] data = new String[10];
int color;
int attr_type;
int access;
int cycle;
String ref_object;
}
double max_value;
double min_value;
double bar_value;
int bar_bordercolor;
int bar_borderwidth;
int bar_drawtype;
TraceData trace = new TraceData();
Object userdata;
public GrowBar(GrowCmn cmn) {
super(cmn);
}
public GrowBar( 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) {
super(cmn, n_name, x, y, w, h, draw_type, line_width, fill, border, shadow, fill_drawtype);
}
public int type() {
return Glow.eObjectType_GrowBar;
}
public void open(BufferedReader reader) {
String line;
StringTokenizer token;
boolean end_found = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "GrowBar : " + line);
switch ( key) {
case Glow.eSave_GrowBar:
break;
case Glow.eSave_GrowBar_max_value:
max_value = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowBar_min_value:
min_value = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowBar_bar_value:
bar_value = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowBar_bar_bordercolor:
bar_bordercolor = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowBar_bar_borderwidth:
bar_borderwidth = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowBar_bar_drawtype:
bar_drawtype = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowBar_rect_part:
super.open( reader);
break;
case Glow.eSave_GrowBar_trace_data1:
if ( token.hasMoreTokens())
trace.data[0] = token.nextToken();
break;
case Glow.eSave_GrowBar_trace_data2:
if ( token.hasMoreTokens())
trace.data[1] = token.nextToken();
break;
case Glow.eSave_GrowBar_trace_data3:
if ( token.hasMoreTokens())
trace.data[2] = token.nextToken();
break;
case Glow.eSave_GrowBar_trace_data4:
if ( token.hasMoreTokens())
trace.data[3] = token.nextToken();
break;
case Glow.eSave_GrowBar_trace_data5:
if ( token.hasMoreTokens())
trace.data[4] = token.nextToken();
break;
case Glow.eSave_GrowBar_trace_data6:
if ( token.hasMoreTokens())
trace.data[5] = token.nextToken();
break;
case Glow.eSave_GrowBar_trace_data7:
if ( token.hasMoreTokens())
trace.data[6] = token.nextToken();
break;
case Glow.eSave_GrowBar_trace_data8:
if ( token.hasMoreTokens())
trace.data[7] = token.nextToken();
break;
case Glow.eSave_GrowBar_trace_data9:
if ( token.hasMoreTokens())
trace.data[8] = token.nextToken();
break;
case Glow.eSave_GrowBar_trace_data10:
if ( token.hasMoreTokens())
trace.data[9] = token.nextToken();
break;
case Glow.eSave_GrowBar_trace_attr_type:
trace.attr_type = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowBar_trace_color:
trace.color = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowBar_access:
trace.access = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowBar_cycle:
trace.cycle = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowBar_ref_object:
if ( token.hasMoreTokens())
trace.ref_object = token.nextToken();
break;
case Glow.eSave_GrowBar_userdata_cb:
if ( cmn.appl != null)
userdata = cmn.appl.growUserdataOpen( reader, this, Glow.eUserdataCbType_Node);
break;
case Glow.eSave_End:
end_found = true;
break;
default:
System.out.println( "Syntax error in GrowBar");
break;
}
if ( end_found)
break;
}
} catch ( Exception e) {
System.out.println( "IOException GrowBar");
}
}
public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {
int idx;
int drawtype;
double rotation;
int grad = gradient;
if ( gradient == Glow.eGradient_No &&
(node != null && ((GrowNode)node).gradient != Glow.eGradient_No) && disable_gradient == 0)
grad = ((GrowNode)node).gradient;
int bar_border_idx = (int)( cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor *
bar_borderwidth - 1);
bar_border_idx = Math.min( Glow.DRAW_TYPE_SIZE - 1, Math.max( 0, bar_border_idx));
if ( node != null && ((GrowNode)node).line_width != 0)
idx = (int)( cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor *
((GrowNode)node).line_width - 1);
else
idx = (int)( cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * line_width - 1);
idx += hot;
idx = Math.max( 0, idx);
idx = Math.min( idx, Glow.DRAW_TYPE_SIZE-1);
int x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;
if ( t == null) {
x1 = (int)( trf.x( ll.x, ll.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
y1 = (int)( trf.y( ll.x, ll.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
x2 = (int)( trf.x( ur.x, ur.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
y2 = (int)( trf.y( ur.x, ur.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
}
else {
x1 = (int)( trf.x( t, ll.x, ll.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
y1 = (int)( trf.y( t, ll.x, ll.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
x2 = (int)( trf.x( t, ur.x, ur.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
y2 = (int)( trf.y( t, ur.x, ur.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_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 ( fill != 0) {
drawtype = GlowColor.get_drawtype( fill_drawtype, Glow.eDrawType_FillHighlight,
highlight, colornode, 1, 0);
if ( grad == Glow.eGradient_No)
cmn.gdraw.fill_rect( ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype);
else {
int f1, f2;
if ( t != null)
rotation = trf.rot( t);
else
rotation = trf.rot();
if ( gradient_contrast >= 0) {
f2 = GlowColor.shift_drawtype( drawtype, -gradient_contrast/2, null);
f1 = GlowColor.shift_drawtype( drawtype, (int)((float)(gradient_contrast)/2+0.6), null);
}
else {
f2 = GlowColor.shift_drawtype( drawtype, -(int)((float)(gradient_contrast)/2-0.6), null);
f1 = GlowColor.shift_drawtype( drawtype, gradient_contrast/2, null);
}
cmn.gdraw.gradient_fill_rect( ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, f1, f2, cmn.gdraw.gradient_rotate( rotation, grad));
}
}
drawtype = GlowColor.get_drawtype( draw_type, Glow.eDrawType_LineHighlight,
highlight, (GrowNode)colornode, 0, 0);
if ( max_value != min_value) {
int x0, y0, width, height, l_x0, l_y0, l_x1, l_y1;
if ( t != null)
rotation = (trf.rot( t) / 360 - Math.floor( trf.rot( t) / 360)) * 360;
else
rotation = (trf.rot() / 360 - Math.floor( trf.rot() / 360)) * 360;
if ( 45 >= rotation || rotation > 315) {
height = (int)( (bar_value - min_value) / (max_value - min_value)
* (ur_y - ll_y));
height = Math.max( 0, Math.min( height, ur_y - ll_y));
width = ur_x - ll_x;
x0 = ll_x;
y0 = ur_y - height;
l_x0 = ll_x;
l_y0 = ur_y - height;
l_x1 = ur_x;
l_y1 = ur_y - height;
}
else if ( 45 < rotation && rotation <= 135) {
width = (int)( (bar_value - min_value) / (max_value - min_value) *
(ur_x - ll_x));
width = Math.max( 0, Math.min( width, ur_x - ll_x));
height = ur_y - ll_y;
x0 = ll_x;
y0 = ll_y;
l_x0 = ll_x + width;
l_y0 = ll_y;
l_x1 = ll_x + width;
l_y1 = ur_y;
}
else if ( 135 < rotation && rotation <= 225) {
height = (int)( (bar_value - min_value) / (max_value - min_value) *
(ur_y - ll_y));
height = Math.max( 0, Math.min( height, ur_y - ll_y));
width = ur_x - ll_x;
x0 = ll_x;
y0 = ll_y;
l_x0 = ll_x;
l_y0 = ll_y + height;
l_x1 = ur_x;
l_y1 = ll_y + height;
}
else { // if ( 225 < rotation && rotation <= 315)
width = (int)( (bar_value - min_value) / (max_value - min_value) *
(ur_x - ll_x));
width = Math.max( 0, Math.min( width, ur_x - ll_x));
height = ur_y - ll_y;
x0 = ur_x - width;
y0 = ll_y;
l_x0 = ur_x - width;
l_y0 = ll_y;
l_x1 = ur_x - width;
l_y1 = ur_y;
}
int dt = drawtype;
if ( bar_drawtype != Glow.eDrawType_Inherit)
dt = bar_drawtype;
if ( grad == Glow.eGradient_No)
cmn.gdraw.fill_rect( x0, y0, width, height, dt);
else {
int f1, f2;
if ( t != null)
rotation = trf.rot( t);
else
rotation = trf.rot();
if ( gradient_contrast >= 0) {
f2 = GlowColor.shift_drawtype( dt, -gradient_contrast/2, null);
f1 = GlowColor.shift_drawtype( dt, (int)((float)(gradient_contrast)/2+0.6), null);
}
else {
f2 = GlowColor.shift_drawtype( dt, -(int)((float)(gradient_contrast)/2-0.6), null);
f1 = GlowColor.shift_drawtype( dt, gradient_contrast/2, null);
}
cmn.gdraw.gradient_fill_rect( x0, y0, width, height, dt, f1, f2, cmn.gdraw.gradient_rotate( rotation, grad));
}
dt = drawtype;
if ( bar_bordercolor != Glow.eDrawType_Inherit)
dt = bar_bordercolor;
cmn.gdraw.line( l_x0, l_y0, l_x1, l_y1, dt, bar_border_idx, 0);
}
if ( border != 0) {
cmn.gdraw.rect( ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, idx, 0);
}
}
public void set_range( double min, double max) {
max_value = max;
min_value = min;
draw();
}
public void set_value( double value) {
bar_value = value;
draw();
}
public Object getUserData() {
return userdata;
}
}
......@@ -103,7 +103,13 @@ public class GrowCmn {
int callback_object_type;
int hot_mode;
int hot_found;
GlowArrayElem restriction_object;
int move_restriction;
double restriction_max_limit;
double restriction_min_limit;
int recursive_trace;
public int nodraw;
Vector<GlowArrayElem> a = new Vector<GlowArrayElem>();
Vector<GlowArrayElem> a_nc = new Vector<GlowArrayElem>();
Vector<GlowArrayElem> a_cc = new Vector<GlowArrayElem>();
......
......@@ -44,6 +44,11 @@ import jpwr.rt.*;
public class GrowCtx implements GrowCtxIfc {
GrowCmn cmn;
String name;
boolean sliderActive;
GrowSlider sliderObject;
double node_move_last_x;
double node_move_last_y;
double slider_cursor_offset;
public GrowCtx(GrowApplIfc appl) {
cmn = new GrowCmn( this, appl);
......@@ -168,6 +173,18 @@ public class GrowCtx implements GrowCtxIfc {
}
public void open_comment( BufferedReader reader) {
String line;
try {
while( (line = reader.readLine()) != null) {
if ( !line.startsWith("!"))
break;
if ( line.startsWith("!*/"))
break;
}
} catch ( Exception e) {
System.out.println( "IOException GlowCtx comment");
}
}
public void open_grow( BufferedReader reader) {
......@@ -318,6 +335,9 @@ public class GrowCtx implements GrowCtxIfc {
case Glow.eSave_GrowCtx_input_focus_mark:
cmn.input_focus_mark = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowCtx_recursive_trace:
cmn.recursive_trace = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowCtx_userdata_cb:
if ( cmn.appl != null)
cmn.userdata = cmn.appl.growUserdataOpen(reader, cmn, Glow.eUserdataCbType_Ctx);
......@@ -331,6 +351,9 @@ public class GrowCtx implements GrowCtxIfc {
if ( end_found)
break;
}
cmn.mw.offset_x = (int)(cmn.x0 * cmn.mw.zoom_factor_x);
cmn.mw.offset_y = (int)(cmn.y0 * cmn.mw.zoom_factor_y);
} catch ( Exception e) {
System.out.println( "IOException GrowCtx");
}
......@@ -374,6 +397,9 @@ public class GrowCtx implements GrowCtxIfc {
public void eventHandler(GlowEvent e) {
int sts = 0;
double x = e.x * cmn.mw.zoom_factor_x - cmn.mw.offset_x;
double y = e.y * cmn.mw.zoom_factor_y - cmn.mw.offset_y;
cmn.callback_object = null;
cmn.callback_object_type = Glow.eObjectType_NoObject;
for ( int i = cmn.a.size() - 1; i >= 0; i--) {
......@@ -383,6 +409,159 @@ public class GrowCtx implements GrowCtxIfc {
}
}
switch ( e.event) {
case Glow.eEvent_MB1Down:
if ( sts == 1 && cmn.callback_object.type() == Glow.eObjectType_GrowSlider) {
System.out.println("Slider start");
sliderActive = true;
sliderObject = (GrowSlider)cmn.callback_object;
GlowEvent se = new GlowEvent();
se.event = Glow.eEvent_SliderMoveStart;
se.type = Glow.eEventType_Object;
se.x = e.x;
se.y = e.y;
se.object = cmn.callback_object;
se.object_type = cmn.callback_object.type();
cmn.appl.eventHandler(se);
if ( cmn.restriction_object != null) {
GlowGeometry g = ((GrowSlider)cmn.restriction_object).measure();
if (cmn.move_restriction == Glow.eMoveRestriction_VerticalSlider)
slider_cursor_offset = g.ll_y - e.y;
else
slider_cursor_offset = g.ll_x - e.x;
}
node_move_last_x = e.x;
node_move_last_y = e.y;
}
break;
case Glow.eEvent_MB1Up:
if ( sliderActive) {
if ( cmn.restriction_object != null) {
System.out.println("Slider end");
GlowEvent se = new GlowEvent();
se.event = Glow.eEvent_SliderMoveEnd;
se.type = Glow.eEventType_Object;
se.x = e.x;
se.y = e.y;
se.object = cmn.restriction_object;
se.object_type = cmn.restriction_object.type();
cmn.appl.eventHandler(se);
cmn.restriction_object = null;
}
sliderObject = null;
sliderActive = false;
}
break;
case Glow.eEvent_ButtonMotion:
if ( sliderActive && cmn.restriction_object != null) {
double move_x, move_y;
double cursor_y, cursor_x;
switch( cmn.move_restriction) {
case Glow.eMoveRestriction_VerticalSlider: {
cursor_y = e.y;
if ( cursor_y + slider_cursor_offset > cmn.restriction_max_limit) {
if ( node_move_last_y + slider_cursor_offset > cmn.restriction_max_limit)
break;
else {
move_y = cmn.restriction_max_limit - node_move_last_y -
slider_cursor_offset;
System.out.println("Slider max limit: " + move_y + " limit " + cmn.restriction_max_limit);
}
}
else if ( cursor_y + slider_cursor_offset < cmn.restriction_min_limit) {
if ( node_move_last_y + slider_cursor_offset < cmn.restriction_min_limit)
break;
else
move_y = cmn.restriction_min_limit - node_move_last_y -
slider_cursor_offset;
}
else {
if ( node_move_last_y + slider_cursor_offset > cmn.restriction_max_limit)
move_y = cursor_y + slider_cursor_offset -
cmn.restriction_max_limit;
else if ( node_move_last_y + slider_cursor_offset < cmn.restriction_min_limit)
move_y = cursor_y + slider_cursor_offset -
cmn.restriction_min_limit;
else
move_y = e.y - node_move_last_y;
}
if ( move_y == 0)
break;
// set_defered_redraw();
((GrowSlider)cmn.restriction_object).move( 0, move_y);
// redraw_defered();
GlowEvent se = new GlowEvent();
se.event = Glow.eEvent_SliderMoved;
se.type = Glow.eEventType_Object;
se.x = e.x;
se.y = node_move_last_y + move_y;
se.object = cmn.restriction_object;
se.object_type = cmn.restriction_object.type();
cmn.appl.eventHandler(se);
node_move_last_x = e.x;
node_move_last_y = e.y;
break;
}
case Glow.eMoveRestriction_HorizontalSlider: {
cursor_x = e.x;
if ( cursor_x + slider_cursor_offset > cmn.restriction_max_limit) {
if ( node_move_last_x +
slider_cursor_offset > cmn.restriction_max_limit)
break;
else
move_x = cmn.restriction_max_limit -
node_move_last_x - slider_cursor_offset;
}
else if ( cursor_x + slider_cursor_offset < cmn.restriction_min_limit) {
if ( node_move_last_x +
slider_cursor_offset < cmn.restriction_min_limit)
break;
else
move_x = cmn.restriction_min_limit -
node_move_last_x - slider_cursor_offset;
}
else {
if ( node_move_last_x + slider_cursor_offset > cmn.restriction_max_limit)
move_x = cursor_x + slider_cursor_offset -
cmn.restriction_max_limit;
else if ( node_move_last_x + slider_cursor_offset < cmn.restriction_min_limit)
move_x = cursor_x + slider_cursor_offset -
cmn.restriction_min_limit;
else
move_x = e.x - node_move_last_x;
}
if ( move_x == 0)
break;
// set_defered_redraw();
((GrowSlider)cmn.restriction_object).move( move_x, 0);
GlowGeometry g = ((GrowSlider)cmn.restriction_object).measure();
// redraw_defered();
GlowEvent se = new GlowEvent();
se.event = Glow.eEvent_SliderMoved;
se.type = Glow.eEventType_Object;
se.x = node_move_last_x + move_x;
se.y = e.y;
se.object = cmn.restriction_object;
se.object_type = cmn.restriction_object.type();
cmn.appl.eventHandler(se);
node_move_last_x = e.x;
node_move_last_y = e.y;
}
break;
}
}
}
if ( sts == 1 && cmn.appl != null) {
e.object = cmn.callback_object;
e.object_type = cmn.callback_object_type;
......@@ -392,10 +571,14 @@ public class GrowCtx implements GrowCtxIfc {
public void traceConnect() {
int sts;
cmn.nodraw++;
for ( int i = 0; i < cmn.a.size(); i++) {
if ( cmn.a.get(i).type() == Glow.eObjectType_GrowNode ||
cmn.a.get(i).type() == Glow.eObjectType_GrowGroup) {
cmn.appl.traceConnect((GrowNode)cmn.a.get(i));
cmn.a.get(i).type() == Glow.eObjectType_GrowGroup ||
cmn.a.get(i).type() == Glow.eObjectType_GrowBar ||
cmn.a.get(i).type() == Glow.eObjectType_GrowTrend ||
cmn.a.get(i).type() == Glow.eObjectType_GrowSlider) {
cmn.appl.traceConnect(cmn.a.get(i));
if ( cmn.a.get(i).type() == Glow.eObjectType_GrowGroup) {
for ( int j = 0; j < ((GrowNode)cmn.a.get(i)).nc.a.size(); j++) {
if ( ((GrowNode)cmn.a.get(i)).nc.a.get(j).type() == Glow.eObjectType_GrowNode ||
......@@ -407,14 +590,18 @@ public class GrowCtx implements GrowCtxIfc {
}
}
}
cmn.nodraw--;
}
public void traceDisconnect() {
int sts;
for ( int i = 0; i < cmn.a.size(); i++) {
if ( cmn.a.get(i).type() == Glow.eObjectType_GrowNode ||
cmn.a.get(i).type() == Glow.eObjectType_GrowGroup) {
cmn.appl.traceDisconnect((GrowNode)cmn.a.get(i));
cmn.a.get(i).type() == Glow.eObjectType_GrowGroup ||
cmn.a.get(i).type() == Glow.eObjectType_GrowBar ||
cmn.a.get(i).type() == Glow.eObjectType_GrowTrend ||
cmn.a.get(i).type() == Glow.eObjectType_GrowSlider) {
cmn.appl.traceDisconnect(cmn.a.get(i));
if ( cmn.a.get(i).type() == Glow.eObjectType_GrowGroup) {
for ( int j = 0; j < ((GrowNode)cmn.a.get(i)).nc.a.size(); j++) {
if ( ((GrowNode)cmn.a.get(i)).nc.a.get(j).type() == Glow.eObjectType_GrowNode ||
......@@ -431,8 +618,11 @@ public class GrowCtx implements GrowCtxIfc {
int sts;
for ( int i = 0; i < cmn.a.size(); i++) {
if ( cmn.a.get(i).type() == Glow.eObjectType_GrowNode ||
cmn.a.get(i).type() == Glow.eObjectType_GrowGroup) {
cmn.appl.traceScan((GrowNode)cmn.a.get(i));
cmn.a.get(i).type() == Glow.eObjectType_GrowGroup ||
cmn.a.get(i).type() == Glow.eObjectType_GrowBar ||
cmn.a.get(i).type() == Glow.eObjectType_GrowTrend ||
cmn.a.get(i).type() == Glow.eObjectType_GrowSlider) {
cmn.appl.traceScan(cmn.a.get(i));
if ( cmn.a.get(i).type() == Glow.eObjectType_GrowGroup) {
for ( int j = 0; j < ((GrowNode)cmn.a.get(i)).nc.a.size(); j++) {
if ( ((GrowNode)cmn.a.get(i)).nc.a.get(j).type() == Glow.eObjectType_GrowNode ||
......@@ -480,6 +670,27 @@ public class GrowCtx implements GrowCtxIfc {
public Vector<GlowArrayElem> get_object_list() {
return cmn.a;
}
public GlowBackgroundObject getBackgroundObjectLimits(int type, double x, double y) {
int sts = 0;
GlowBackgroundObject b = new GlowBackgroundObject();
for ( int i = 0; i < cmn.a.size(); i++) {
sts = cmn.a.get(i).get_background_object_limits(null, type, x, y, b);
if ( (sts & 1) != 0)
break;
}
b.sts = sts;
return b;
}
public void setMoveRestrictions( int restriction, double max_limit, double min_limit, GlowArrayElem object) {
cmn.move_restriction = restriction;
cmn.restriction_max_limit = max_limit;
cmn.restriction_min_limit = min_limit;
cmn.restriction_object = object;
}
}
......
......@@ -50,4 +50,6 @@ public interface GrowCtxIfc {
public void remove(GlowArrayElem e);
public void pop(GlowArrayElem e);
public Vector<GlowArrayElem> get_object_list();
public GlowBackgroundObject getBackgroundObjectLimits(int type, double x, double y);
public void setMoveRestrictions( int restriction, double max_limit, double min_limit, GlowArrayElem object);
}
......@@ -36,7 +36,6 @@
package jpwr.jopg;
import jpwr.jop.*;
import jpwr.rt.*;
import java.io.*;
import java.awt.*;
......@@ -64,13 +63,17 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
JLabel confirmLabel;
Object confirmDyn;
Object confirmObject;
String instance;
GrowFrameApplIfc appl;
public GrowFrame( String file) {
public GrowFrame( String file, Gdh gdh, String instance, GrowFrameApplIfc appl) {
root = (Object) this;
init( file);
this.instance = instance;
this.appl = appl;
init( file, gdh);
}
private void init( String file) {
private void init( String file, Gdh gdh) {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
contentPane.add(localPanel, BorderLayout.CENTER);
......@@ -86,7 +89,7 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
BufferedReader reader = null;
String fname = file;
if ( root != null && root instanceof JopApplet) {
if ( root != null && root instanceof JApplet) {
try {
URL current = ((JApplet) root).getCodeBase();
String current_str = current.toString();
......@@ -109,7 +112,10 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
}
}
else {
filename = "$pwrp_exe/" + fname;
if ( fname.lastIndexOf('/') == -1)
filename = "$pwrp_exe/" + fname;
else
filename = fname;
filename = Gdh.translateFilename( filename);
System.out.println( "Fname: " + filename);
......@@ -120,9 +126,33 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
System.out.println( "Unable to open file " + filename);
return;
}
// Read size info
String line;
int defaultWidth = 0;
int defaultHeight = 0;
try {
for ( int i = 0; i < 2; i++) {
line = reader.readLine();
if ( line == null || !line.startsWith("0! "))
break;
if ( line.substring(3, 15).equals("DefaultWidth"))
defaultWidth = new Integer(line.substring(16)).intValue();
else if ( line.substring(3, 16).equals("DefaultHeight"))
defaultHeight = new Integer(line.substring(17)).intValue();
}
} catch ( Exception e) {
System.out.println( "IOException GlowFrame");
}
System.out.println("GraphFrame size " + defaultWidth + " " + defaultHeight);
if ( defaultWidth != 0 && defaultHeight != 0) {
size = new Dimension( defaultWidth + 5, defaultHeight + 40);
setSize( size);
}
}
Gdh gdh = new Gdh(this);
if ( gdh == null)
gdh = new Gdh(this);
graph = new Graph(this, gdh);
graph.open(reader);
......@@ -162,6 +192,13 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
event.event = Glow.eEvent_CursorMotion;
graph.ctx.eventHandler( event);
}
public void mouseDragged(MouseEvent e) {
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.event = Glow.eEvent_ButtonMotion;
graph.ctx.eventHandler( event);
}
};
localPanel.addMouseListener(adapter);
......@@ -173,10 +210,10 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
public int getWidth() {
return localPanel.getWidth();
return localPanel.getWidth() + 5;
}
public int getHeight() {
return localPanel.getHeight();
return localPanel.getHeight() + 40;
}
public void actionPerformed( ActionEvent e) {
......@@ -189,8 +226,8 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
}
void setSize() {
size = new Dimension( (int)((graph.ctx.cmn.x_right - graph.ctx.cmn.x_left) * graph.ctx.cmn.mw.zoom_factor_x) + Flow.DRAWOFFSET * 2,
(int)((graph.ctx.cmn.y_high - graph.ctx.cmn.y_low) * graph.ctx.cmn.mw.zoom_factor_y) + Flow.DRAWOFFSET * 2);
size = new Dimension( (int)((graph.ctx.cmn.x_right - graph.ctx.cmn.x_left) * graph.ctx.cmn.mw.zoom_factor_x) + Glow.DRAWOFFSET * 2,
(int)((graph.ctx.cmn.y_high - graph.ctx.cmn.y_low) * graph.ctx.cmn.mw.zoom_factor_y) + Glow.DRAWOFFSET * 2);
localPanel.setPreferredSize( size);
localPanel.revalidate();
}
......@@ -224,7 +261,9 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
public int command(String cmd) {
System.out.println("Ge command : " + cmd);
return 1;
if ( appl != null)
return appl.command(cmd);
return 0;
}
public void confirmNo() {}
......@@ -281,7 +320,9 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
}
}
public String getObject() {
return instance;
}
}
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
package jpwr.jopg;
public interface GrowFrameApplIfc {
public int command(String cmd);
}
......@@ -82,7 +82,8 @@ public class GrowLine extends GlowArrayElem {
case Glow.eSave_GrowLine:
break;
case Glow.eSave_GrowLine_n_name:
n_name = token.nextToken();
if ( token.hasMoreTokens())
n_name = token.nextToken();
break;
case Glow.eSave_GrowLine_x_right:
x_right = new Double(token.nextToken()).doubleValue();
......
......@@ -134,15 +134,15 @@ public class GrowMenu extends GrowRect {
// Outside window border
ur_y = cmn.getHeight() + cmn.mw.subwindow_y;
ll_y = ur_y - (int)(tot_z_height);
ll.posit( ll.x, ll_y * cmn.mw.zoom_factor_x + cmn.mw.offset_y);
ur.posit( ur.x, ur_y * cmn.mw.zoom_factor_y + cmn.mw.offset_y); // Might not always be correct?
ll.posit( ll.x, (ll_y + cmn.mw.offset_y) / cmn.mw.zoom_factor_x);
ur.posit( ur.x, (ur_y + cmn.mw.offset_y) / cmn.mw.zoom_factor_y); // Might not always be correct?
ll_x = (int)( ll.x * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
ll_y = (int)( ll.y * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
ur_x = ll_x + max_z_width + 15 + (int)(pulldown_found * arrow_size);
ur_y = ll_y + (int)(tot_z_height);
}
else
ur.posit( ur_x * cmn.mw.zoom_factor_x + cmn.mw.offset_x, ur_y *cmn.mw.zoom_factor_y + cmn.mw.offset_y);
ur.posit( (ur_x + cmn.mw.offset_x)/ cmn.mw.zoom_factor_x, (ur_y + cmn.mw.offset_y)/ cmn.mw.zoom_factor_y);
ll_y = (int)( ll.y * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
get_node_borders();
System.out.println("Menu borders: (" + x_left + "," + y_low + ") (" + x_right + "," + y_high + ")");
......
......@@ -256,7 +256,8 @@ public class GrowNode extends GlowArrayElem {
nc_root = nc;
break;
case Glow.eSave_Node_n_name:
n_name = token.nextToken();
if ( token.hasMoreTokens())
n_name = token.nextToken();
break;
case Glow.eSave_Node_refcon_cnt:
for ( int i = 0; i < MAX_CONPOINTS; i++)
......@@ -668,10 +669,34 @@ public class GrowNode extends GlowArrayElem {
get_node_borders();
}
void storeTransform() {
public void storeTransform() {
trf.store();
}
public boolean transformIsStored() {
return trf.is_stored();
}
void get_node_borders() {
GlowGeometry g = new GlowGeometry();
g.ur_x = 10e-37;
g.ll_x = 10e37;
g.ur_y = 10e-37;
g.ll_y = 10e37;
nc.get_borders( trf, g);
x_left = g.ll_x;
x_right = g.ur_x;
y_low = g.ll_y;
y_high = g.ur_y;
}
public void get_borders( GlowTransform t, GlowGeometry g) {
if ( t != null) {
GlowTransform t2 = t.multiply(trf);
nc.get_borders(t2, g);
}
else
nc.get_borders(trf, g);
}
int set_next_nodeclass() {
......@@ -799,4 +824,140 @@ public class GrowNode extends GlowArrayElem {
return geom;
}
public void move_to( double x, double y) {
double old_x_left = x_left;
double old_x_right = x_right;
double old_y_low = y_low;
double old_y_high = y_high;
trf.move( x - x_left, y - y_low);
get_node_borders();
//draw();
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);
}
public void move( double x, double y) {
double old_x_left = x_left;
double old_x_right = x_right;
double old_y_low = y_low;
double old_y_high = y_high;
trf.move( x, y);
get_node_borders();
//draw();
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);
}
public void set_position( double x, double y) {
double old_x_left, old_x_right, old_y_low, old_y_high;
if ( trf.a13 == trf.s_a13 + x && trf.a23 == trf.s_a23 + y)
return;
old_x_left = x_left;
old_x_right = x_right;
old_y_low = y_low;
old_y_high = y_high;
trf.move_from_stored( x, y);
get_node_borders();
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);
}
public int get_background_object_limits(GlowTransform t, int type, double x, double y, GlowBackgroundObject b) {
int dyn_type;
GlowNodeClass base_nc = nc.get_base_nc();
dyn_type = base_nc.dyn_type1;
if ( (type & dyn_type) == 0)
return 0;
if ( nc.y0 == 0 && nc.y1 == 0)
return 0;
double x1, x2, y1, y2;
double rotation;
GlowGeometry g = new GlowGeometry();
g.ur_x = 10e-37;
g.ll_x = 10e37;
g.ur_y = 10e-37;
g.ll_y = 10e37;
get_borders( t, g);
double x1_right = g.ur_x;
double x1_left = g.ll_x;
double y1_high = g.ur_y;
double y1_low = g.ll_y;
System.out.println("Slider background: ("+x+","+y+") ("+x1_left+","+y1_low+") ("+x1_right+","+y1_high+")");
if ( x <= x1_right && x >= x1_left && y <= y1_high && y >= y1_low) {
// Hit, calculate max and min koordinates
if (t == null) {
x1 = trf.x( 0, nc.y0);
y1 = trf.y( 0, nc.y0);
x2 = trf.x( 0, nc.y1);
y2 = trf.y( 0, nc.y1);
}
else {
x1 = trf.x( t, 0, nc.y0);
y1 = trf.y( t, 0, nc.y0);
x2 = trf.x( t, 0, nc.y1);
y2 = trf.y( t, 0, nc.y1);
}
if ( t != null)
rotation = (trf.rot( t) / 360 - Math.floor( trf.rot( t) / 360)) * 360;
else {
rotation = (trf.rot() / 360 - Math.floor( trf.rot() / 360)) * 360;
System.out.println("trf.rotation" + trf.rotation + " floor: " + Math.floor( trf.rot() / 360));
}
if ( 45 >= rotation || rotation > 315) {
b.direction = Glow.eDirection_Down;
b.min = y1;
b.max = y2;
}
else if ( 45 < rotation && rotation <= 135) {
b.direction = Glow.eDirection_Left;
b.min = x2;
b.max = x1;
}
else if ( 135 < rotation && rotation <= 225) {
b.direction = Glow.eDirection_Up;
b.min = y2;
b.max = y1;
}
else if ( 225 < rotation && rotation <= 315) {
b.direction = Glow.eDirection_Right;
b.min = x1;
b.max = x2;
}
b.background = this;
System.out.println("Background limits (" + g.ll_x + "," + g.ll_y + ") (" + g.ur_x + "," + g.ur_y + ") rot " + rotation);
return 1;
}
return 0;
}
}
......@@ -86,6 +86,37 @@ public class GrowPolyline extends GlowArrayElem {
trf = new GlowTransform();
}
public GrowPolyline( GrowCmn cmn, String name,
GlowPoint[] pointarray, int point_cnt,
int border_d_type, int line_w,
int fix_line_w, int fill, int display_border, int display_shadow,
int fill_d_type) {
this.cmn = cmn;
original_border_drawtype = border_d_type;
fill_drawtype = fill_d_type;
border = display_border;
shadow = display_shadow;
shadow_width = 5;
relief = Glow.eRelief_Up;
shadow_contrast = 2;
gradient = Glow.eGradient_No;
gradient_contrast = 4;
n_name = name;
draw_type = border_d_type;
line_width = line_w;
this.fill = fill;
for ( int i = 0; i < point_cnt; i++)
a_points.add(new GlowPoint(pointarray[i]));
points = new GlowPointX[a_points.size()];
for ( int i = 0; i < a_points.size(); i++)
points[i] = new GlowPointX();
trf = new GlowTransform();
}
public int type() {
return Glow.eObjectType_GrowPolyLine;
}
......@@ -105,7 +136,8 @@ public class GrowPolyline extends GlowArrayElem {
case Glow.eSave_GrowPolyLine:
break;
case Glow.eSave_GrowPolyLine_n_name:
n_name = token.nextToken();
if ( token.hasMoreTokens())
n_name = token.nextToken();
break;
case Glow.eSave_GrowPolyLine_x_right:
x_right = new Double(token.nextToken()).doubleValue();
......@@ -282,7 +314,6 @@ public class GrowPolyline extends GlowArrayElem {
public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {
int chot = 0;
if ( hot != 0) {
if ( cmn.hot_indication == Glow.eHotIndication_No)
......@@ -322,7 +353,6 @@ public class GrowPolyline extends GlowArrayElem {
x1 = trf.x( t, a_points.get(i).x, a_points.get(i).y);
y1 = trf.y( t, a_points.get(i).x, a_points.get(i).y);
}
points[i].x = (int)( x1 * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
points[i].y = (int)( y1 * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
}
......@@ -647,4 +677,68 @@ public class GrowPolyline extends GlowArrayElem {
}
return dir;
}
public void add_and_shift_y_value( double value) {
for ( int i = a_points.size() - 1; i > 0; i--) {
a_points.get(i).y = a_points.get(i-1).y;
}
a_points.get(0).y = value;
}
public void add_and_shift_y_value_filled( double value) {
for ( int i = a_points.size() - 2; i > 1; i--) {
a_points.get(i).y = a_points.get(i-1).y;
}
a_points.get(1).y = value;
}
public void get_borders( GlowTransform t, GlowGeometry g) {
int i;
double x1, y1, x2=0, y2=0;
for ( i = 0; i < a_points.size() - 1; i++) {
if ( t != null) {
if ( i == 0) {
x1 = trf.x( t, a_points.get(i).x, a_points.get(i).y);
y1 = trf.y( t, a_points.get(i).x, a_points.get(i).y);
}
else {
x1 = x2;
y1 = y2;
}
x2 = trf.x( t, a_points.get(i).x, a_points.get(i).y);
y2 = trf.y( t, a_points.get(i).x, a_points.get(i).y);
}
else {
if ( i == 0) {
x1 = trf.x( a_points.get(i).x, a_points.get(i).y);
y1 = trf.y( a_points.get(i).x, a_points.get(i).y);
}
else {
x1 = x2;
y1 = y2;
}
x2 = trf.x( a_points.get(i+1).x, a_points.get(i+1).y);
y2 = trf.y( a_points.get(i+1).x, a_points.get(i+1).y);
}
if ( x1 < g.ll_x)
g.ll_x = x1;
if ( x2 < g.ll_x)
g.ll_x = x2;
if ( x1 > g.ur_x)
g.ur_x = x1;
if ( x2 > g.ur_x)
g.ur_x = x2;
if ( y1 < g.ll_y)
g.ll_y = y1;
if ( y2 < g.ll_y)
g.ll_y = y2;
if ( y1 > g.ur_y)
g.ur_y = y1;
if ( y2 > g.ur_y)
g.ur_y = y2;
}
}
}
......@@ -124,7 +124,8 @@ public class GrowRect extends GlowArrayElem {
case Glow.eSave_GrowRect:
break;
case Glow.eSave_GrowRect_n_name:
n_name = token.nextToken();
if ( token.hasMoreTokens())
n_name = token.nextToken();
break;
case Glow.eSave_GrowRect_x_right:
x_right = new Double(token.nextToken()).doubleValue();
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
package jpwr.jopg;
import jpwr.rt.*;
import java.io.*;
import java.util.*;
public class GrowSlider extends GrowNode {
int direction;
double max_value;
double min_value;
double max_pos;
double min_pos;
public GrowSlider(GrowCmn cmn) {
super(cmn);
}
public int type() {
return Glow.eObjectType_GrowSlider;
}
public void open(BufferedReader reader) {
String line;
StringTokenizer token;
boolean end_found = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "GrowSlider : " + line);
switch ( key) {
case Glow.eSave_GrowSlider:
break;
case Glow.eSave_GrowSlider_direction:
direction = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowSlider_max_value:
max_value = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowSlider_min_value:
min_value = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowSlider_max_pos:
max_pos = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowSlider_min_pos:
min_pos = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowSlider_grownode_part:
super.open(reader);
break;
case Glow.eSave_End:
end_found = true;
break;
default:
System.out.println( "Syntax error in GrowSlider");
break;
}
if ( end_found)
break;
}
} catch ( Exception e) {
System.out.println( "IOException GrowSlider");
}
}
public void draw() {
super.draw();
}
public double get_origo( int direction) {
GlowTransform t = new GlowTransform();
GlowGeometry g = new GlowGeometry();
g.ur_x = 10e-37;
g.ll_x = 10e37;
g.ur_y = 10e-37;
g.ll_y = 10e37;
double pos;
// Get borders in the nodeclass coordinates
nc.get_borders( t, g);
switch ( direction) {
case Glow.eDirection_Down:
case Glow.eDirection_Up:
if ( Math.abs(g.ur_y - g.ll_y) < Double.MIN_VALUE)
pos = y_low;
else
pos = (nc.y0 - g.ll_y) * (y_high - y_low) / (g.ur_y - g.ll_y);
break;
case Glow.eDirection_Left:
case Glow.eDirection_Right:
if ( Math.abs(g.ur_y - g.ll_y) < Double.MIN_VALUE)
pos = y_low;
else
pos = (nc.y0 - g.ll_y) * (x_right - x_left) / (g.ur_y - g.ll_y);
break;
default:
pos = 0;
}
return pos;
}
public GlowSliderInfo get_info() {
GlowSliderInfo info = new GlowSliderInfo();
info.direction = direction;
info.max_value = max_value;
info.min_value = min_value;
info.max_position = max_pos;
info.min_position = min_pos;
return info;
}
public void set_info(GlowSliderInfo info) {
direction = info.direction;
max_value = info.max_value;
min_value = info.min_value;
max_pos = info.max_position;
min_pos = info.min_position;
}
}
......@@ -48,7 +48,7 @@ public class GrowText extends GlowArrayElem {
double y_low;
int original_color_drawtype;
int font;
int adjustment;
int adjustment = Glow.eAdjustment_Left;
int dynamicsize;
GlowTransform trf;
......@@ -80,7 +80,8 @@ public class GrowText extends GlowArrayElem {
case Glow.eSave_GrowText:
break;
case Glow.eSave_GrowText_n_name:
n_name = token.nextToken();
if ( token.hasMoreTokens())
n_name = token.nextToken();
break;
case Glow.eSave_GrowText_x_right:
x_right = new Double(token.nextToken()).doubleValue();
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
package jpwr.jopg;
import jpwr.rt.*;
import java.io.*;
import java.util.*;
public class GrowTrend extends GrowRect {
class TraceData{
String[] data = new String[10];
int color;
int attr_type;
int access;
int cycle;
String ref_object;
}
double[] y_max_value = new double[Glow.TREND_MAX_CURVES];
double[] y_min_value = new double[Glow.TREND_MAX_CURVES];
double[] x_max_value = new double[Glow.TREND_MAX_CURVES];
double[] x_min_value = new double[Glow.TREND_MAX_CURVES];
int vertical_lines;
int horizontal_lines;
int fill_curve;
int no_of_points;
int curve_width;
int[] curve_drawtype = new int[Glow.TREND_MAX_CURVES];
int[] curve_fill_drawtype = new int[Glow.TREND_MAX_CURVES];
double scan_time;
GrowPolyline[] curve = new GrowPolyline[Glow.TREND_MAX_CURVES];
int curve_cnt = 1;
TraceData trace = new TraceData();
Object userdata;
public GrowTrend(GrowCmn cmn) {
super(cmn);
}
public GrowTrend( 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) {
super(cmn, n_name, x, y, w, h, draw_type, line_width, fill, border, shadow, fill_drawtype);
}
public int type() {
return Glow.eObjectType_GrowTrend;
}
public void open(BufferedReader reader) {
String line;
StringTokenizer token;
boolean end_found = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "GrowTrend : " + line);
switch ( key) {
case Glow.eSave_GrowTrend:
break;
case Glow.eSave_GrowTrend_y_max_value_0:
y_max_value[0] = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowTrend_y_max_value_1:
y_max_value[1] = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowTrend_y_min_value_0:
y_min_value[0] = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowTrend_y_min_value_1:
y_min_value[1] = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowTrend_x_max_value_0:
x_max_value[0] = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowTrend_x_max_value_1:
x_max_value[1] = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowTrend_x_min_value_0:
x_min_value[0] = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowTrend_x_min_value_1:
x_min_value[1] = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowTrend_horizontal_lines:
horizontal_lines = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_vertical_lines:
vertical_lines = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_fill_curve:
fill_curve = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_curve_drawtype_0:
curve_drawtype[0] = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_curve_drawtype_1:
curve_drawtype[1] = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_curve_fill_drawtype_0:
curve_fill_drawtype[0] = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_curve_fill_drawtype_1:
curve_fill_drawtype[1] = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_no_of_points:
no_of_points = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_curve_width:
curve_width = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_scan_time:
scan_time = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowTrend_rect_part:
super.open( reader);
break;
case Glow.eSave_GrowTrend_trace_data1:
if ( token.hasMoreTokens())
trace.data[0] = token.nextToken();
break;
case Glow.eSave_GrowTrend_trace_data2:
if ( token.hasMoreTokens())
trace.data[1] = token.nextToken();
break;
case Glow.eSave_GrowTrend_trace_data3:
if ( token.hasMoreTokens())
trace.data[2] = token.nextToken();
break;
case Glow.eSave_GrowTrend_trace_data4:
if ( token.hasMoreTokens())
trace.data[3] = token.nextToken();
break;
case Glow.eSave_GrowTrend_trace_data5:
if ( token.hasMoreTokens())
trace.data[4] = token.nextToken();
break;
case Glow.eSave_GrowTrend_trace_data6:
if ( token.hasMoreTokens())
trace.data[5] = token.nextToken();
break;
case Glow.eSave_GrowTrend_trace_data7:
if ( token.hasMoreTokens())
trace.data[6] = token.nextToken();
break;
case Glow.eSave_GrowTrend_trace_data8:
if ( token.hasMoreTokens())
trace.data[7] = token.nextToken();
break;
case Glow.eSave_GrowTrend_trace_data9:
if ( token.hasMoreTokens())
trace.data[8] = token.nextToken();
break;
case Glow.eSave_GrowTrend_trace_data10:
if ( token.hasMoreTokens())
trace.data[9] = token.nextToken();
break;
case Glow.eSave_GrowTrend_trace_attr_type:
trace.attr_type = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_trace_color:
trace.color = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_access:
trace.access = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_cycle:
trace.cycle = new Integer(token.nextToken()).intValue();
break;
case Glow.eSave_GrowTrend_ref_object:
if ( token.hasMoreTokens())
trace.ref_object = token.nextToken();
break;
case Glow.eSave_GrowTrend_userdata_cb:
if ( cmn.appl != null)
userdata = cmn.appl.growUserdataOpen( reader, this, Glow.eUserdataCbType_Node);
break;
case Glow.eSave_End:
end_found = true;
break;
default:
System.out.println( "Syntax error in GrowTrend");
break;
}
if ( end_found)
break;
}
configure_curves();
} catch ( Exception e) {
System.out.println( "IOException GrowTrend");
}
}
public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {
if ( cmn.nodraw != 0)
return;
int i;
int idx;
int drawtype;
if ( node != null && ((GrowNode)node).line_width != 0)
idx = (int)( cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor *
((GrowNode)node).line_width - 1);
else
idx = (int)( cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * line_width - 1);
idx += hot;
idx = Math.max( 0, idx);
idx = Math.min( idx, Glow.DRAW_TYPE_SIZE-1);
int x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;
if (t == null) {
x1 = (int)( trf.x( ll.x, ll.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
y1 = (int)( trf.y( ll.x, ll.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
x2 = (int)( trf.x( ur.x, ur.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
y2 = (int)( trf.y( ur.x, ur.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
}
else {
x1 = (int)( trf.x( t, ll.x, ll.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
y1 = (int)( trf.y( t, ll.x, ll.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
x2 = (int)( trf.x( t, ur.x, ur.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
y2 = (int)( trf.y( t, ur.x, ur.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_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 ( fill != 0) {
int grad = gradient;
if ( gradient == Glow.eGradient_No &&
(node != null && ((GrowNode)node).gradient != Glow.eGradient_No) && disable_gradient == 0)
grad = ((GrowNode)node).gradient;
drawtype = GlowColor.get_drawtype( fill_drawtype, Glow.eDrawType_FillHighlight,
highlight, colornode, 1, 0);
if ( grad == Glow.eGradient_No)
cmn.gdraw.fill_rect( ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype);
else {
int f1, f2;
double rotation;
if ( t != null)
rotation = trf.rot( t);
else
rotation = trf.rot();
if ( gradient_contrast >= 0) {
f2 = GlowColor.shift_drawtype( drawtype, -gradient_contrast/2, 0);
f1 = GlowColor.shift_drawtype( drawtype, (int)((float)(gradient_contrast)/2+0.6), 0);
}
else {
f2 = GlowColor.shift_drawtype( drawtype, -(int)((float)(gradient_contrast)/2-0.6), 0);
f1 = GlowColor.shift_drawtype( drawtype, gradient_contrast/2, 0);
}
cmn.gdraw.gradient_fill_rect( ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, f1, f2, cmn.gdraw.gradient_rotate( rotation, grad));
}
}
drawtype = GlowColor.get_drawtype( draw_type, Glow.eDrawType_LineHighlight,
highlight, colornode, 0, 0);
if ( fill_curve != 0) {
for ( i = 0; i < curve_cnt; i++) {
if ( curve[i] != null)
curve[i].border = 0;
}
if ( t != null) {
GlowTransform tmp = t.multiply(trf);
for ( i = 0; i < curve_cnt; i++) {
if ( curve[i] != null)
curve[i].draw( tmp, highlight, hot, node, colornode);
}
}
else {
for ( i = 0; i < curve_cnt; i++) {
if ( curve[i] != null)
curve[i].draw( trf, highlight, hot, node, colornode);
}
}
for ( i = 0; i < curve_cnt; i++) {
if ( curve[i] != null)
curve[i].border = 1;
}
}
for ( i = 0; i < vertical_lines; i++) {
int x = (int)( ll_x + (double)(ur_x - ll_x) / (vertical_lines + 1) * (i + 1));
cmn.gdraw.line( x, ll_y, x, ur_y, drawtype, 0, 0);
}
for ( i = 0; i < horizontal_lines; i++) {
int y = (int)( ll_y + (double)(ur_y - ll_y) / (horizontal_lines + 1) * (i + 1));
cmn.gdraw.line( ll_x, y, ur_x, y, drawtype, 0, 0);
}
if ( fill_curve != 0) {
for ( i = 0; i < curve_cnt; i++) {
if ( curve[i] != null)
curve[i].fill = 0;
}
}
if ( t != null) {
GlowTransform tmp = t.multiply(trf);
for ( i = 0; i < curve_cnt; i++) {
if ( curve[i] != null)
curve[i].draw( tmp, highlight, hot, node, colornode);
}
}
else {
for ( i = 0; i < curve_cnt; i++) {
if ( curve[i] != null)
curve[i].draw( trf, highlight, hot, node, colornode);
}
}
if ( fill_curve != 0) {
for ( i = 0; i < curve_cnt; i++) {
if ( curve[i] != null)
curve[i].fill = 1;
}
}
if ( border != 0) {
cmn.gdraw.rect( ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, idx, 0);
}
}
public void set_range( int curve, double min, double max) {
if ( !( curve == 0 || curve == 1))
return;
y_max_value[curve] = max;
y_min_value[curve] = min;
configure_curves();
}
public Object getUserData() {
return userdata;
}
void configure_curves() {
int dt, dt_fill;
int points;
GlowPoint[] pointarray;
GlowPoint point_p;
int i;
if ( false /* strcmp( trace.data[1], "") == 0 */ )
curve_cnt = 1;
else
curve_cnt = 2;
no_of_points = Math.max( 2, no_of_points);
points = no_of_points;
if ( fill_curve != 0)
points += 2;
curve_width = Math.min( Glow.DRAW_TYPE_SIZE, Math.max( 1, curve_width));
pointarray = new GlowPoint[points];
for ( i = 0; i < points; i++) {
pointarray[i] = new GlowPoint(cmn);
point_p = pointarray[i];
if ( fill_curve == 0) {
point_p.y = ur.y;
point_p.x = ur.x - i * (ur.x - ll.x) / (points - 1);
}
else {
point_p.y = ur.y;
if ( i == 0)
point_p.x = ur.x;
else if ( i == points - 1)
point_p.x = ll.x;
else
point_p.x = ur.x - (i - 1) * (ur.x - ll.x) / (points - 3);
}
}
for ( i = 0; i < curve_cnt; i++) {
if ( curve[i] != null)
curve[i] = null;
if ( curve_drawtype[i] != Glow.eDrawType_Inherit)
dt = curve_drawtype[i];
else
dt = draw_type;
if ( curve_fill_drawtype[i] != Glow.eDrawType_Inherit)
dt_fill = curve_fill_drawtype[i];
else
dt_fill = draw_type;
cmn.nodraw++;
curve[i] = new GrowPolyline( cmn, "", pointarray, points, dt,
curve_width,
0, fill_curve, 1, 0, dt_fill);
cmn.nodraw--;
}
}
public void set_range_y( int curve, double min, double max) {
if ( !( curve == 0 || curve == 1))
return;
y_max_value[curve] = max;
y_min_value[curve] = min;
configure_curves();
}
public void add_value( double value, int idx) {
double curve_value = 0;
if ( idx >= curve_cnt)
return;
if ( y_max_value[idx] != y_min_value[idx])
curve_value = ur.y - (value - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
curve_value = Math.max( ll.y, Math.min( curve_value, ur.y));
if ( fill_curve == 0)
curve[idx].add_and_shift_y_value( curve_value);
else
curve[idx].add_and_shift_y_value_filled( curve_value);
draw();
}
public double get_scan_time() {
return scan_time;
}
}
......@@ -8,6 +8,8 @@ local_java_sources := \
GlowGeometry.java,\
GlowPointX.java,\
GlowDimension.java,\
GlowSliderInfo.java,\
GlowBackgroundObject.java,\
GlowMenuInfo.java,\
GrowApplIfc.java,\
GlowColorRgb.java,\
......@@ -27,6 +29,7 @@ local_java_sources := \
GlowConPoint.java,\
GrowNode.java,\
GrowGroup.java,\
GrowSlider.java,\
GrowRect.java,\
GrowArc.java,\
GrowLine.java,\
......@@ -34,6 +37,8 @@ local_java_sources := \
GrowText.java,\
GrowAnnot.java,\
GrowMenu.java,\
GrowBar.java,\
GrowTrend.java,\
GlowVector.java,\
GrowCtx.java,\
DynParsedAttrName.java,\
......@@ -42,6 +47,7 @@ local_java_sources := \
Dyn.java,\
GraphApplIfc.java,\
Graph.java,\
GrowFrameApplIfc.java,\
GrowFrame.java
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
......
......@@ -23,6 +23,6 @@ done < $bootfile
echo $systemname
export CLASSPATH=$pwr_lib/pwr_rt.jar:$pwr_lib/pwr_jop.jar:$pwr_lib/pwr_jopc.jar:$pwr_lib/pwr_bcomp.jar:$pwr_lib/pwr_bcompfc.jar:$pwr_lib/pwr_abb.jar:$pwrp_lib/pwrp_$systemname.jar
export CLASSPATH=$pwr_lib/pwr_rt.jar:$pwr_lib/pwr_jop.jar:$pwr_lib/pwr_jopg.jar:$pwr_lib/pwr_jopc.jar:$pwr_lib/pwr_bcomp.jar:$pwr_lib/pwr_bcompfc.jar:$pwr_lib/pwr_abb.jar:$pwrp_lib/pwrp_$systemname.jar
export LD_LIBRARY_PATH=$pwr_exe
$jdk/bin/java jpwr.jop.JopOp
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