Commit 782e95a1 authored by Claes Sjofors's avatar Claes Sjofors

PwrXtt android application build tree added

parent 9cf54e99
package jpwr.app;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.Vector;
import android.graphics.Color;
import android.os.AsyncTask;
import jpwr.pwrxtt.R;
import jpwr.rt.*;
public class AEv {
final static int PORT = 4446;
public PlowCmn cmnAla;
public PlowCmn cmnEve;
public PlowNodeClass alaNcAlarm;
public PlowNodeClass alaNcAAlarm;
public PlowNodeClass alaNcBAlarm;
public PlowNodeClass alaNcCAlarm;
public PlowNodeClass alaNcDAlarm;
public PlowNodeClass eveNcAlarm;
public PlowNodeClass eveNcAAlarm;
public PlowNodeClass eveNcBAlarm;
public PlowNodeClass eveNcCAlarm;
public PlowNodeClass eveNcDAlarm;
public PlowNodeClass eveNcInfo;
public PlowPixmapData iconEventAlarm;
public PlowPixmapData iconEventAcked;
public PlowPixmapData iconEventReturn;
public PlowPixmapData iconEventBlock;
public PlowPixmapData iconEventUnblock;
public PlowPixmapData iconAlarmActive;
public PlowPixmapData iconAlarmNotAcked;
Socket mhSocket;
String pwrHost;
AEvAppl appl;
AEv aev;
int maxNrOfAlarms = 100;
int maxNrOfEvents = 100;
boolean sendAck;
MhrsEventId ackEventId;
public AEv(PlowCmn cmnAla, PlowCmn cmnEve, AEvAppl appl) {
this.cmnAla = cmnAla;
this.cmnEve = cmnEve;
this.pwrHost = appl.getPwrHost();
this.appl = appl;
aev = this;
createPixmaps();
createNodeClasses();
new MhReceiveTask().execute();
}
public PlowCmn getCmnAla() {
return cmnAla;
}
public PlowCmn getCmnEve() {
return cmnEve;
}
public void newMess(MhrEvent ev) {
switch (ev.eventType) {
case Mh.mh_eEvent_Alarm:
// Add to alarm and event list
new AEvItemAlarm(aev, ev, null, Plow.DEST_AFTER);
cmnAla.configure();
new AEvItemEvent(aev, ev, null, Plow.DEST_AFTER);
cmnEve.configure();
break;
case Mh.mh_eEvent_Return:
for( PlowNode n = (PlowNode)cmnAla.getFirst(); n != null; n = (PlowNode)cmnAla.getNext(n)) {
AEvItemAlarm item = (AEvItemAlarm)n.getUserData();
if ((ev.targetId.nix == item.e.eventId.nix) && (ev.targetId.idx == item.e.eventId.idx)) {
// The alarm is acknowledged and can be removed
if((item.e.eventStatus & Mh.mh_mEventStatus_NotAck) == 0) {
cmnAla.remove(n);
cmnAla.configure();
}
else {
// Set the return bit and display it
item.e.eventStatus &= ~Mh.mh_mEventStatus_NotRet;
item.update(this);
}
break;
}
}
if((ev.eventFlags & Mh.mh_mEventFlags_Return) != 0) {
// Add copy to event list
new AEvItemEvent(aev, ev, null, Plow.DEST_AFTER);
cmnEve.configure();
}
break;
case Mh.mh_eEvent_Ack:
for( PlowNode n = (PlowNode)cmnAla.getFirst(); n != null; n = (PlowNode)cmnAla.getNext(n)) {
AEvItemAlarm item = (AEvItemAlarm)n.getUserData();
if((ev.targetId.nix == item.e.eventId.nix) && (ev.targetId.idx == item.e.eventId.idx)) {
if((item.e.eventStatus & Mh.mh_mEventStatus_NotRet) == 0) {
cmnAla.remove(n);
cmnAla.configure();
}
else {
item.e.eventStatus &= ~Mh.mh_mEventStatus_NotAck;
item.update(this);
}
break;
}
}
if((ev.eventFlags & Mh.mh_mEventFlags_Ack) != 0) {
// Add copy to event list
new AEvItemEvent(aev, ev, null, Plow.DEST_AFTER);
cmnEve.configure();
}
break;
case Mh.mh_eEvent_Info:
// Add to alarm list
if((ev.eventFlags & Mh.mh_mEventFlags_InfoWindow) != 0) {
new AEvItemAlarm(aev, ev, null, Plow.DEST_AFTER);
cmnAla.configure();
}
// Add copy to event list
new AEvItemEvent(aev, ev, null, Plow.DEST_AFTER);
cmnEve.configure();
break;
case Mh.EventType_ClearAlarmList:
cmnAla.clear();
cmnAla.configure();
System.out.println("Clearing alarmlist");
break;
default:
break;
}
if(cmnAla.size() > maxNrOfAlarms) {
PlowNode n = (PlowNode)cmnAla.getLast();
cmnAla.remove(n);
}
if(cmnEve.size() > maxNrOfEvents) {
PlowNode n = (PlowNode)cmnAla.getLast();
cmnEve.remove(n);
}
}
public void createPixmaps() {
// Eve pixmaps
iconEventAlarm = new PlowPixmapData(cmnEve, new int[] {R.drawable.xnav_bitmap_eventalarm8, R.drawable.xnav_bitmap_eventalarm10,
R.drawable.xnav_bitmap_eventalarm12, R.drawable.xnav_bitmap_eventalarm14, R.drawable.xnav_bitmap_eventalarm16,
R.drawable.xnav_bitmap_eventalarm18, R.drawable.xnav_bitmap_eventalarm20, R.drawable.xnav_bitmap_eventalarm24});
iconEventAcked = new PlowPixmapData(cmnEve, new int[] {R.drawable.xnav_bitmap_eventacked8, R.drawable.xnav_bitmap_eventacked10,
R.drawable.xnav_bitmap_eventacked12, R.drawable.xnav_bitmap_eventacked14, R.drawable.xnav_bitmap_eventacked16,
R.drawable.xnav_bitmap_eventacked18, R.drawable.xnav_bitmap_eventacked20, R.drawable.xnav_bitmap_eventacked24});
iconEventReturn = new PlowPixmapData(cmnEve, new int[] {R.drawable.xnav_bitmap_eventreturn8, R.drawable.xnav_bitmap_eventreturn10,
R.drawable.xnav_bitmap_eventreturn12, R.drawable.xnav_bitmap_eventreturn14, R.drawable.xnav_bitmap_eventreturn16,
R.drawable.xnav_bitmap_eventreturn18, R.drawable.xnav_bitmap_eventreturn20, R.drawable.xnav_bitmap_eventreturn24});
iconEventBlock = new PlowPixmapData(cmnEve, new int[] {R.drawable.xnav_bitmap_blockr_8, R.drawable.xnav_bitmap_blockr_10,
R.drawable.xnav_bitmap_blockr_12, R.drawable.xnav_bitmap_blockr_14, R.drawable.xnav_bitmap_blockr_16,
R.drawable.xnav_bitmap_blockr_18, R.drawable.xnav_bitmap_blockr_20, R.drawable.xnav_bitmap_blockr_24});
iconEventUnblock = new PlowPixmapData(cmnEve, new int[] {R.drawable.xnav_bitmap_blockl_8, R.drawable.xnav_bitmap_blockl_10,
R.drawable.xnav_bitmap_blockl_12, R.drawable.xnav_bitmap_blockl_14, R.drawable.xnav_bitmap_blockl_16,
R.drawable.xnav_bitmap_blockl_18, R.drawable.xnav_bitmap_blockl_20, R.drawable.xnav_bitmap_blockl_24});
// Ala pixmaps
iconAlarmActive = new PlowPixmapData(cmnAla, new int[] {R.drawable.xnav_bitmap_alarm8, R.drawable.xnav_bitmap_alarm10,
R.drawable.xnav_bitmap_alarm12, R.drawable.xnav_bitmap_alarm14, R.drawable.xnav_bitmap_alarm16,
R.drawable.xnav_bitmap_alarm18, R.drawable.xnav_bitmap_alarm20, R.drawable.xnav_bitmap_alarm24});
iconAlarmNotAcked = new PlowPixmapData(cmnAla, new int[] {R.drawable.xnav_bitmap_ack8, R.drawable.xnav_bitmap_ack10,
R.drawable.xnav_bitmap_ack12, R.drawable.xnav_bitmap_ack14, R.drawable.xnav_bitmap_ack16,
R.drawable.xnav_bitmap_ack18, R.drawable.xnav_bitmap_ack20, R.drawable.xnav_bitmap_ack24});
}
public void createNodeClasses() {
// Ala nodeclasses
PlowRect r1 = new PlowRect(cmnAla, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
PlowRect r2 = new PlowRect(cmnAla, 0.4D, 0.3D, 0.9D, 0.9D, Plow.COLOR_RED, Plow.COLOR_BLACK,true,true,true);
PlowAnnot a1 = new PlowAnnot(cmnAla, 4D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
PlowAnnot a2 = new PlowAnnot(cmnAla, 10D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
PlowAnnot a3 = new PlowAnnot(cmnAla, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
PlowAnnotPixmap p1 = new PlowAnnotPixmap(cmnAla, 2D, 0.28D, 0);
PlowAnnotPixmap p2 = new PlowAnnotPixmap(cmnAla, 3D, 0.28D, 1);
alaNcAAlarm = new PlowNodeClass(cmnAla);
alaNcAAlarm.insert(r1);
alaNcAAlarm.insert(r2);
alaNcAAlarm.insert(a1);
alaNcAAlarm.insert(a2);
alaNcAAlarm.insert(a3);
alaNcAAlarm.insert(p1);
alaNcAAlarm.insert(p2);
cmnAla.insert_nc(alaNcAAlarm);
r1 = new PlowRect(cmnAla, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
r2 = new PlowRect(cmnAla, 0.4D, 0.3D, 0.9D, 0.9D, Plow.COLOR_YELLOW, Plow.COLOR_BLACK,true,true,true);
a1 = new PlowAnnot(cmnAla, 4D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
a2 = new PlowAnnot(cmnAla, 10D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
a3 = new PlowAnnot(cmnAla, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
p1 = new PlowAnnotPixmap(cmnAla, 2D, 0.28D, 0);
p2 = new PlowAnnotPixmap(cmnAla, 3D, 0.28D, 1);
alaNcBAlarm = new PlowNodeClass(cmnAla);
alaNcBAlarm.insert(r1);
alaNcBAlarm.insert(r2);
alaNcBAlarm.insert(a1);
alaNcBAlarm.insert(a2);
alaNcBAlarm.insert(a3);
alaNcBAlarm.insert(p1);
alaNcBAlarm.insert(p2);
cmnAla.insert_nc(alaNcBAlarm);
r1 = new PlowRect(cmnAla, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
r2 = new PlowRect(cmnAla, 0.4D, 0.3D, 0.9D, 0.9D, Plow.COLOR_BLUE, Plow.COLOR_BLACK,true,true,true);
a1 = new PlowAnnot(cmnAla, 4D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
a2 = new PlowAnnot(cmnAla, 10D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
a3 = new PlowAnnot(cmnAla, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
p1 = new PlowAnnotPixmap(cmnAla, 2D, 0.28D, 0);
p2 = new PlowAnnotPixmap(cmnAla, 3D, 0.28D, 1);
alaNcCAlarm = new PlowNodeClass(cmnAla);
alaNcCAlarm.insert(r1);
alaNcCAlarm.insert(r2);
alaNcCAlarm.insert(a1);
alaNcCAlarm.insert(a2);
alaNcCAlarm.insert(a3);
alaNcCAlarm.insert(p1);
alaNcCAlarm.insert(p2);
cmnAla.insert_nc(alaNcCAlarm);
r1 = new PlowRect(cmnAla, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
r2 = new PlowRect(cmnAla, 0.4D, 0.3D, 0.9D, 0.9D, Plow.COLOR_VIOLET, Plow.COLOR_BLACK,true,true,true);
a1 = new PlowAnnot(cmnAla, 4D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
a2 = new PlowAnnot(cmnAla, 10D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
a3 = new PlowAnnot(cmnAla, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
p1 = new PlowAnnotPixmap(cmnAla, 2D, 0.28D, 0);
p2 = new PlowAnnotPixmap(cmnAla, 3D, 0.28D, 1);
alaNcDAlarm = new PlowNodeClass(cmnAla);
alaNcDAlarm.insert(r1);
alaNcDAlarm.insert(r2);
alaNcDAlarm.insert(a1);
alaNcDAlarm.insert(a2);
alaNcDAlarm.insert(a3);
alaNcDAlarm.insert(p1);
alaNcDAlarm.insert(p2);
cmnAla.insert_nc(alaNcDAlarm);
r1 = new PlowRect(cmnAla, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
a1 = new PlowAnnot(cmnAla, 5D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
a2 = new PlowAnnot(cmnAla, 11D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
a3 = new PlowAnnot(cmnAla, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
p1 = new PlowAnnotPixmap(cmnAla, 2D, 0.28D, 0);
p2 = new PlowAnnotPixmap(cmnAla, 3D, 0.28D, 1);
alaNcAlarm = new PlowNodeClass(cmnAla);
alaNcAlarm.insert(r1);
alaNcAlarm.insert(a1);
alaNcAlarm.insert(a2);
alaNcAlarm.insert(a3);
alaNcAlarm.insert(p1);
alaNcAlarm.insert(p2);
cmnAla.insert_nc(alaNcAlarm);
// Eve nodeclass
r1 = new PlowRect(cmnEve, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
r2 = new PlowRect(cmnEve, 0.4D, 0.3D, 0.9D, 0.9D, Plow.COLOR_RED, Plow.COLOR_BLACK,true,true,true);
a1 = new PlowAnnot(cmnEve, 4D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
a2 = new PlowAnnot(cmnEve, 10D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
a3 = new PlowAnnot(cmnEve, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
p1 = new PlowAnnotPixmap(cmnEve, 2D, 0.28D, 0);
eveNcAAlarm = new PlowNodeClass(cmnEve);
eveNcAAlarm.insert(r1);
eveNcAAlarm.insert(r2);
eveNcAAlarm.insert(a1);
eveNcAAlarm.insert(a2);
eveNcAAlarm.insert(a3);
eveNcAAlarm.insert(p1);
cmnEve.insert_nc(eveNcAAlarm);
r1 = new PlowRect(cmnEve, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
r2 = new PlowRect(cmnEve, 0.4D, 0.3D, 0.9D, 0.9D, Plow.COLOR_YELLOW, Plow.COLOR_BLACK,true,true,true);
a1 = new PlowAnnot(cmnEve, 4D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
a2 = new PlowAnnot(cmnEve, 10D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
a3 = new PlowAnnot(cmnEve, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
p1 = new PlowAnnotPixmap(cmnEve, 2D, 0.28D, 0);
eveNcBAlarm = new PlowNodeClass(cmnEve);
eveNcBAlarm.insert(r1);
eveNcBAlarm.insert(r2);
eveNcBAlarm.insert(a1);
eveNcBAlarm.insert(a2);
eveNcBAlarm.insert(a3);
eveNcBAlarm.insert(p1);
cmnEve.insert_nc(eveNcBAlarm);
r1 = new PlowRect(cmnEve, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
r2 = new PlowRect(cmnEve, 0.4D, 0.3D, 0.9D, 0.9D, Plow.COLOR_BLUE, Plow.COLOR_BLACK,true,true,true);
a1 = new PlowAnnot(cmnEve, 4D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
a2 = new PlowAnnot(cmnEve, 10D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
a3 = new PlowAnnot(cmnEve, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
p1 = new PlowAnnotPixmap(cmnEve, 2D, 0.28D, 0);
eveNcCAlarm = new PlowNodeClass(cmnEve);
eveNcCAlarm.insert(r1);
eveNcCAlarm.insert(r2);
eveNcCAlarm.insert(a1);
eveNcCAlarm.insert(a2);
eveNcCAlarm.insert(a3);
eveNcCAlarm.insert(p1);
cmnEve.insert_nc(eveNcCAlarm);
r1 = new PlowRect(cmnEve, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
r2 = new PlowRect(cmnEve, 0.4D, 0.3D, 0.9D, 0.9D, Plow.COLOR_VIOLET, Plow.COLOR_BLACK,true,true,true);
a1 = new PlowAnnot(cmnEve, 4D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
a2 = new PlowAnnot(cmnEve, 10D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
a3 = new PlowAnnot(cmnEve, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
p1 = new PlowAnnotPixmap(cmnEve, 2D, 0.28D, 0);
eveNcDAlarm = new PlowNodeClass(cmnEve);
eveNcDAlarm.insert(r1);
eveNcDAlarm.insert(r2);
eveNcDAlarm.insert(a1);
eveNcDAlarm.insert(a2);
eveNcDAlarm.insert(a3);
eveNcDAlarm.insert(p1);
cmnEve.insert_nc(eveNcDAlarm);
r1 = new PlowRect(cmnEve, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
r2 = new PlowRect(cmnEve, 0.4D, 0.3D, 0.9D, 0.9D, Plow.COLOR_GREEN, Plow.COLOR_BLACK,true,true,true);
a1 = new PlowAnnot(cmnEve, 4D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
a2 = new PlowAnnot(cmnEve, 10D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
a3 = new PlowAnnot(cmnEve, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
p1 = new PlowAnnotPixmap(cmnEve, 2D, 0.28D, 0);
eveNcInfo = new PlowNodeClass(cmnEve);
eveNcInfo.insert(r1);
eveNcInfo.insert(r2);
eveNcInfo.insert(a1);
eveNcInfo.insert(a2);
eveNcInfo.insert(a3);
eveNcInfo.insert(p1);
cmnEve.insert_nc(eveNcInfo);
r1 = new PlowRect(cmnEve, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
a1 = new PlowAnnot(cmnEve, 4D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
a2 = new PlowAnnot(cmnEve, 10D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
a3 = new PlowAnnot(cmnEve, 26D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 2);
p1 = new PlowAnnotPixmap(cmnEve, 2D, 0.28D, 0);
eveNcAlarm = new PlowNodeClass(cmnEve);
eveNcAlarm.insert(r1);
eveNcAlarm.insert(a1);
eveNcAlarm.insert(a2);
eveNcAlarm.insert(a3);
eveNcAlarm.insert(p1);
cmnEve.insert_nc(eveNcAlarm);
}
public void acknowledge() {
for( PlowNode n = (PlowNode)cmnAla.getFirst(); n != null; n = (PlowNode)cmnAla.getNext(n)) {
AEvItemAlarm item = (AEvItemAlarm)n.getUserData();
if((item.e.eventStatus & Mh.mh_mEventStatus_NotAck) != 0) {
ackEventId = item.e.eventId;
sendAck = true;
break;
}
}
}
private class MhReceiveTask extends AsyncTask<Void, Void, Void> {
ObjectInputStream in;
ObjectOutputStream out;
boolean keepRunning = true;
@Override
protected Void doInBackground(Void... params) {
try {
mhSocket = new Socket(pwrHost, PORT);
mhSocket.setKeepAlive(true);
out = new ObjectOutputStream( mhSocket.getOutputStream());
out.flush();
in = new ObjectInputStream( mhSocket.getInputStream());
mhSocket.setSoTimeout(1000);
}
catch(IOException e) {
System.out.println("IOException ObjectOutputStream/ObjectInputStream");
return null;
}
try {
maxNrOfAlarms = in.readInt();
if(maxNrOfAlarms == -1) {
System.out.println("Max number of alarm exceeded, restart");
this.keepRunning = false;
}
else {
maxNrOfEvents = in.readInt();
int nrOfAlarms = in.readInt();
if (nrOfAlarms > 0) {
Vector alarmVec = new Vector(nrOfAlarms);
alarmVec = (Vector)in.readObject();
System.out.println("Alarm size " + alarmVec.size());
for ( int i = 0; i < alarmVec.size(); i++) {
System.out.println("Alarm item: " + alarmVec.get(i));
newMess((MhrEvent)alarmVec.get(i));
System.out.println("Alarm: (" + nrOfAlarms + ") " + ((MhrEvent)alarmVec.get(i)).eventPrio + " " + ((MhrEvent)alarmVec.get(i)).eventText + " " + ((MhrEvent)alarmVec.get(i)).eventName );
}
cmnAla.configure();
//appl.invalidateView();
}
int nrOfEvents = in.readInt();
if(nrOfEvents > 0) {
Vector eventVec = new Vector(nrOfEvents);
eventVec = (Vector)in.readObject();
for ( int i = 0; i < eventVec.size(); i++) {
new AEvItemEvent(aev, (MhrEvent)eventVec.get(i), null, Plow.DEST_AFTER);
System.out.println("Event: " + ((MhrEvent)eventVec.get(i)).eventText);
}
cmnEve.configure();
}
}
}
catch(SocketTimeoutException e) {
}
catch(Exception e) {
System.out.println(e.toString());
this.keepRunning = false;
}
while(this.keepRunning) {
try {
// Wait for events messages from server.
MhrEvent ev = (MhrEvent)in.readObject();
newMess(ev);
if (!(appl.getCurrentCmn() == cmnAla || appl.getCurrentCmn() == cmnEve))
this.keepRunning = false;
}
catch(SocketTimeoutException e) {
if (!(appl.getCurrentCmn() == cmnAla || appl.getCurrentCmn() == cmnEve))
this.keepRunning = false;
System.out.println("Timeout " + sendAck + " " + ackEventId);
if ( sendAck && ackEventId != null) {
sendAck = false;
System.out.println("Send ack" + ackEventId);
try {
out.writeObject(ackEventId);
out.flush();
}
catch (Exception ex) {
System.out.println("Mh ack send exception");
}
}
}
catch(ClassNotFoundException e) {
System.out.println("Exception in wait for messages: " + e.toString());
System.out.println("Error, can't interpret message from server");
}
catch(Exception e) {
System.out.println("Exception in wait for messages: " + e.toString());
System.out.println("Terminating");
this.keepRunning = false;
}
}
try {
in.close();
out.close();
}
catch(Exception e) {
}
return null;
}
@Override
protected void onPostExecute(Void params) {
super.onPostExecute(params);
}
}
}
package jpwr.app;
import android.view.View;
import jpwr.rt.*;
import jpwr.app.*;
public interface AEvAppl {
public void invalidateView();
public String getPwrHost();
public PlowCmnIfc getCurrentCmn();
}
package jpwr.app;
import java.util.StringTokenizer;
import java.util.Vector;
import jpwr.rt.*;
import jpwr.app.*;
public class AEvItemAlarm extends AXttItemBase {
static double y = 10D;
public MhrEvent e;
public AEvItemAlarm(AEv aev, MhrEvent e,
PlowNode destination, int destCode) {
this.e = e.getCopy();
System.out.println("New itemalarm Status: " + e.eventStatus + " " + e.eventPrio + " " + e.eventText + " " + e.eventName);
switch ( this.e.eventPrio) {
case Mh.mh_eEventPrio_A:
node = new PlowNode(aev.cmnAla, 3D, y, aev.alaNcAAlarm);
break;
case Mh.mh_eEventPrio_B:
node = new PlowNode(aev.cmnAla, 3D, y, aev.alaNcBAlarm);
break;
case Mh.mh_eEventPrio_C:
node = new PlowNode(aev.cmnAla, 3D, y, aev.alaNcCAlarm);
break;
case Mh.mh_eEventPrio_D:
node = new PlowNode(aev.cmnAla, 3D, y, aev.alaNcDAlarm);
break;
}
node.setAnnotation(0, this.e.eventTime, 1);
node.setAnnotation(1, this.e.eventText, 1);
node.setAnnotation(2, this.e.eventName, 1);
if ( (e.eventStatus & Mh.mh_mEventStatus_NotAck) != 0)
node.setAnnotPixmap(0, aev.iconAlarmNotAcked);
else
node.setAnnotPixmap(0, null);
if ( (e.eventStatus & Mh.mh_mEventStatus_NotRet) != 0)
node.setAnnotPixmap(1, aev.iconAlarmActive);
else
node.setAnnotPixmap(1, null);
aev.cmnAla.insertNode(node, destination, destCode);
y += 1.5D;
node.setUserData(this);
}
public void update(AEv aev) {
if ( (e.eventStatus & Mh.mh_mEventStatus_NotAck) != 0)
node.setAnnotPixmap(0, aev.iconAlarmNotAcked);
else
node.setAnnotPixmap(0, null);
if ( (e.eventStatus & Mh.mh_mEventStatus_NotRet) != 0)
node.setAnnotPixmap(1, aev.iconAlarmActive);
else
node.setAnnotPixmap(1, null);
}
}
package jpwr.app;
import java.util.StringTokenizer;
import java.util.Vector;
import jpwr.rt.*;
import jpwr.app.*;
public class AEvItemEvent extends AXttItemBase {
static double y = 10D;
MhrEvent e;
public PlowNodeClass nc;
public AEvItemEvent(AEv aev, MhrEvent e,
PlowNode destination, int destCode) {
this.e = e.getCopy();
System.out.println("New itemevent: " + e.eventPrio + " " + e.eventText + " " + e.eventName);
switch(this.e.eventType) {
case Mh.mh_eEvent_Info:
nc = aev.eveNcInfo;
break;
case Mh.mh_eEvent_Alarm:
switch ( this.e.eventPrio) {
case Mh.mh_eEventPrio_A:
nc = aev.eveNcAAlarm;
break;
case Mh.mh_eEventPrio_B:
nc = aev.eveNcBAlarm;
break;
case Mh.mh_eEventPrio_C:
nc = aev.eveNcCAlarm;
break;
case Mh.mh_eEventPrio_D:
nc = aev.eveNcDAlarm;
break;
default:
nc = aev.eveNcAlarm;
break;
}
break;
default:
nc = aev.eveNcAlarm;
}
node = new PlowNode(aev.cmnAla, 3D, y, nc);
switch(this.e.eventType) {
case Mh.mh_eEvent_Alarm:
node.setAnnotPixmap(0, aev.iconEventAlarm);
break;
case Mh.mh_eEvent_Ack:
node.setAnnotPixmap(0, aev.iconEventAcked);
break;
case Mh.mh_eEvent_Return:
node.setAnnotPixmap(0, aev.iconEventReturn);
break;
case Mh.mh_eEvent_Block:
node.setAnnotPixmap(0, aev.iconEventBlock);
break;
case Mh.mh_eEvent_Unblock:
node.setAnnotPixmap(0, aev.iconEventUnblock);
break;
}
node.setAnnotation(0, this.e.eventTime, 1);
node.setAnnotation(1, this.e.eventText, 1);
node.setAnnotation(2, this.e.eventName, 1);
aev.cmnEve.insertNode(node, destination, destCode);
y += 1.5D;
node.setUserData(this);
}
}
package jpwr.app;
import android.graphics.Color;
import jpwr.pwrxtt.R;
import jpwr.rt.*;
public class AXtt {
public static final int CRR_READ = 0;
public static final int CRR_WRITE = 1;
public static final int CRR_READWRITE = 2;
public Gdh gdh;
public PlowCmn cmn;
public PlowNodeClass ncObject;
public PlowPixmapData iconMap;
public PlowPixmapData iconOpenmap;
public PlowPixmapData iconLeaf;
public PlowPixmapData iconAttr;
public PlowPixmapData iconAttrArray;
public PlowPixmapData iconAttrArrayElem;
public PlowPixmapData iconAttrEnum;
public PlowPixmapData iconObject;
public PlowPixmapData iconCrrRead;
public PlowPixmapData iconCrrWrite;
public AXtt(PlowCmn cmn, Gdh gdh) {
this.gdh = gdh;
this.cmn = cmn;
createPixmaps();
createNodeClasses();
}
public void createPixmaps() {
// iconOpenmap = new PlowPixmapData(cmn, R.drawable.xtthelp_icon_openmap);
iconLeaf = new PlowPixmapData(cmn, new int[] {R.drawable.xnav_bitmap_leaf8, R.drawable.xnav_bitmap_leaf10,
R.drawable.xnav_bitmap_leaf12, R.drawable.xnav_bitmap_leaf14, R.drawable.xnav_bitmap_leaf16,
R.drawable.xnav_bitmap_leaf18, R.drawable.xnav_bitmap_leaf20, R.drawable.xnav_bitmap_leaf24});
iconOpenmap = new PlowPixmapData(cmn, new int[] {R.drawable.xnav_bitmap_openmap8, R.drawable.xnav_bitmap_openmap10,
R.drawable.xnav_bitmap_openmap12, R.drawable.xnav_bitmap_openmap14, R.drawable.xnav_bitmap_openmap16,
R.drawable.xnav_bitmap_openmap18, R.drawable.xnav_bitmap_openmap20, R.drawable.xnav_bitmap_openmap24});
iconMap = new PlowPixmapData(cmn, new int[] {R.drawable.xnav_bitmap_map8, R.drawable.xnav_bitmap_map10,
R.drawable.xnav_bitmap_map12, R.drawable.xnav_bitmap_map14, R.drawable.xnav_bitmap_map16,
R.drawable.xnav_bitmap_map18, R.drawable.xnav_bitmap_map20, R.drawable.xnav_bitmap_map24});
iconAttr = new PlowPixmapData(cmn, new int[] {R.drawable.xnav_bitmap_attr8, R.drawable.xnav_bitmap_attr10,
R.drawable.xnav_bitmap_attr12, R.drawable.xnav_bitmap_attr14, R.drawable.xnav_bitmap_attr16,
R.drawable.xnav_bitmap_attr18, R.drawable.xnav_bitmap_attr20, R.drawable.xnav_bitmap_attr24});
iconAttrArray = new PlowPixmapData(cmn, new int[] {R.drawable.xnav_bitmap_attrarra8, R.drawable.xnav_bitmap_attrarra10,
R.drawable.xnav_bitmap_attrarra12, R.drawable.xnav_bitmap_attrarra14, R.drawable.xnav_bitmap_attrarra16,
R.drawable.xnav_bitmap_attrarra18, R.drawable.xnav_bitmap_attrarra20, R.drawable.xnav_bitmap_attrarra24});
iconObject = new PlowPixmapData(cmn, new int[] {R.drawable.xnav_bitmap_object8, R.drawable.xnav_bitmap_object10,
R.drawable.xnav_bitmap_object12, R.drawable.xnav_bitmap_object14, R.drawable.xnav_bitmap_object16,
R.drawable.xnav_bitmap_object18, R.drawable.xnav_bitmap_object20, R.drawable.xnav_bitmap_object24});
iconAttrArrayElem = new PlowPixmapData(cmn, new int[] {R.drawable.xnav_bitmap_attrarel8, R.drawable.xnav_bitmap_attrarel10,
R.drawable.xnav_bitmap_attrarel12, R.drawable.xnav_bitmap_attrarel14, R.drawable.xnav_bitmap_attrarel16,
R.drawable.xnav_bitmap_attrarel18, R.drawable.xnav_bitmap_attrarel20, R.drawable.xnav_bitmap_attrarel24});
iconAttrEnum = new PlowPixmapData(cmn, new int[] {R.drawable.xnav_bitmap_attrenum8, R.drawable.xnav_bitmap_attrenum10,
R.drawable.xnav_bitmap_attrenum12, R.drawable.xnav_bitmap_attrenum14, R.drawable.xnav_bitmap_attrenum16,
R.drawable.xnav_bitmap_attrenum18, R.drawable.xnav_bitmap_attrenum20, R.drawable.xnav_bitmap_attrenum24});
iconCrrRead = new PlowPixmapData(cmn, new int[] {R.drawable.xnav_bitmap_crrread8, R.drawable.xnav_bitmap_crrread10,
R.drawable.xnav_bitmap_crrread12, R.drawable.xnav_bitmap_crrread14, R.drawable.xnav_bitmap_crrread16,
R.drawable.xnav_bitmap_crrread18, R.drawable.xnav_bitmap_crrread20, R.drawable.xnav_bitmap_crrread24});
iconCrrWrite = new PlowPixmapData(cmn, new int[] {R.drawable.xnav_bitmap_crrwrite8, R.drawable.xnav_bitmap_crrwrite10,
R.drawable.xnav_bitmap_crrwrite12, R.drawable.xnav_bitmap_crrwrite14, R.drawable.xnav_bitmap_crrwrite16,
R.drawable.xnav_bitmap_crrwrite18, R.drawable.xnav_bitmap_crrwrite20, R.drawable.xnav_bitmap_crrwrite24});
}
public void createNodeClasses() {
PlowRect r1 = new PlowRect(cmn, 0D, 0D, 50D, 1.5D, Plow.COLOR_WHITE, Plow.COLOR_BLACK,true,false,false);
PlowAnnot a1 = new PlowAnnot(cmn, 3D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.NEXT_RELATIVE_POSITION, 0);
PlowAnnot a11 = new PlowAnnot(cmn, 9D, 1.1D, 12, Plow.COLOR_BLACK, 0, PlowAnnot.RELATIVE_POSITION, 1);
PlowAnnotPixmap p1 = new PlowAnnotPixmap(cmn, 1D, 0.28D, 0);
ncObject = new PlowNodeClass(cmn);
ncObject.insert(r1);
ncObject.insert(a1);
ncObject.insert(a11);
ncObject.insert(p1);
cmn.insert_nc(ncObject);
}
}
package jpwr.app;
import jpwr.rt.*;
import jpwr.app.*;
public interface AXttAppl {
public Gdh getGdh();
public PlowCmn getPlowCmn();
}
package jpwr.app;
import jpwr.rt.*;
public class AXttItemAttr extends AXttItemBase {
PwrtObjid objid;
String fullName;
String name;
int flags;
int type;
int refId;
PwrtRefId refRefId;
int refTypeId;
boolean firstScan = true;
float oldValueF;
int oldValueI;
boolean oldValueB;
String oldValueS;
AXttItemAttr(AXtt axtt, PwrtObjid objid, String name, String fullName, int flags, int type,
PlowNode destination, int destCode) {
this.objid = objid;
this.name = name;
this.fullName = fullName;
this.flags = flags;
this.type = type;
this.node = node;
node = new PlowNode(axtt.cmn, 0, 0, axtt.ncObject);
node.setAnnotPixmap(0, axtt.iconAttr);
node.setAnnotation(0, name, 22);
axtt.cmn.insertNode(node, destination, destCode);
node.setUserData(this);
String refName;
switch ( type) {
case Pwr.eType_Boolean:
refName = fullName + "##Boolean";
break;
case Pwr.eType_Float32:
refName = fullName + "##Float32";
break;
case Pwr.eType_Int32:
refName = fullName + "##Int32";
break;
case Pwr.eType_UInt32:
refName = fullName + "##UInt32";
break;
case Pwr.eType_String:
refName = fullName + "##String80";
break;
default:
refName = fullName;
}
GdhrRefObjectInfo ret = axtt.gdh.refObjectInfo(refName);
if ( ret.oddSts()) {
refId = ret.id;
refRefId = ret.refid;
refTypeId = ret.typeId;
}
else
refId = 0;
}
public void close(AXtt axtt) {
if ( refRefId != null)
axtt.gdh.unrefObjectInfo(refRefId);
}
public String getFullName() {
return fullName;
}
public int getType() {
return type;
}
@Override
public void scan(AXtt axtt) {
String valueStr = null;
switch ( type) {
case Pwr.eType_Float32: {
float value = axtt.gdh.getObjectRefInfoFloat(refId);
if ( firstScan || value != oldValueF) {
valueStr = "" + value;
oldValueF = value;
}
break;
}
case Pwr.eType_Boolean: {
boolean value = axtt.gdh.getObjectRefInfoBoolean(refId);
if ( firstScan || value != oldValueB) {
valueStr = "" + (int)(value?1:0);
oldValueB = value;
}
break;
}
case Pwr.eType_Int32:
case Pwr.eType_Int16:
case Pwr.eType_Int8:
case Pwr.eType_UInt32:
case Pwr.eType_UInt16:
case Pwr.eType_UInt8: {
int value = axtt.gdh.getObjectRefInfoInt(refId);
if ( firstScan || value != oldValueI) {
valueStr = "" + value;
oldValueI = value;
}
break;
}
case Pwr.eType_String:
case Pwr.eType_AttrRef:
case Pwr.eType_Objid: {
String value = axtt.gdh.getObjectRefInfoString(refId, refTypeId);
if ( firstScan || value.equals(oldValueS)) {
valueStr = "" + value;
oldValueS = value;
valueStr = value;
}
break;
}
}
if ( valueStr != null)
node.setAnnotation(1, valueStr, 10);
}
}
package jpwr.app;
import java.util.Vector;
import jpwr.rt.CdhrObjAttr;
import jpwr.rt.GdhrRefObjectInfo;
import jpwr.rt.Pwr;
import jpwr.rt.PwrtObjid;
import jpwr.rt.PwrtRefId;
public class AXttItemAttrArray extends AXttItemBase {
PwrtObjid objid;
String fullName;
String name;
int flags;
int type;
int elements;
AXttItemAttrArray(AXtt axtt, PwrtObjid objid, String name, String fullName, int flags, int type,
int elements, PlowNode destination, int destCode) {
this.objid = objid;
this.name = name;
this.fullName = fullName;
this.flags = flags;
this.type = type;
this.elements = elements;
node = new PlowNode(axtt.cmn, 0, 0, axtt.ncObject);
node.setAnnotPixmap(0, axtt.iconAttrArray);
node.setAnnotation(0, name, 22);
axtt.cmn.insertNode(node, destination, destCode);
node.setUserData(this);
}
@Override
public void openAttributes(AXtt axtt) {
if ( (node.getNodeOpen() & Plow.OPEN_ATTRIBUTES) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_ATTRIBUTES);
}
else {
for ( int i = 0; i < elements; i++) {
String fName = fullName + "[" + i + "]";
String aname = name + "[" + i + "]";
if ( (flags & Pwr.mAdef_class) != 0) {
AXttItemAttr item = new AXttItemAttr(axtt, objid, aname, fName,
flags, type, node, Plow.DEST_INTOLAST);
}
else {
AXttItemAttrArrayElem item = new AXttItemAttrArrayElem(axtt, objid, aname, fName,
flags, type, node, Plow.DEST_INTOLAST);
}
}
node.setNodeOpen(Plow.OPEN_ATTRIBUTES);
}
axtt.cmn.configure();
}
@Override
public void close(AXtt axtt) {
}
}
package jpwr.app;
import jpwr.rt.GdhrRefObjectInfo;
import jpwr.rt.Pwr;
import jpwr.rt.PwrtObjid;
import jpwr.rt.PwrtRefId;
public class AXttItemAttrArrayElem extends AXttItemBase {
PwrtObjid objid;
String fullName;
String name;
int flags;
int type;
int refId;
PwrtRefId refRefId;
int refTypeId;
boolean firstScan = true;
float oldValueF;
int oldValueI;
boolean oldValueB;
String oldValueS;
AXttItemAttrArrayElem(AXtt axtt, PwrtObjid objid, String name, String fullName, int flags, int type,
PlowNode destination, int destCode) {
this.objid = objid;
this.name = name;
this.fullName = fullName;
this.flags = flags;
this.type = type;
this.node = node;
node = new PlowNode(axtt.cmn, 0, 0, axtt.ncObject);
node.setAnnotPixmap(0, axtt.iconAttrArrayElem);
node.setAnnotation(0, name, 22);
axtt.cmn.insertNode(node, destination, destCode);
node.setUserData(this);
String refName;
switch ( type) {
case Pwr.eType_Boolean:
refName = fullName + "##Boolean";
break;
case Pwr.eType_Float32:
refName = fullName + "##Float32";
break;
case Pwr.eType_Int32:
refName = fullName + "##Int32";
break;
case Pwr.eType_UInt32:
refName = fullName + "##UInt32";
break;
case Pwr.eType_String:
refName = fullName + "##String80";
break;
default:
refName = fullName;
}
GdhrRefObjectInfo ret = axtt.gdh.refObjectInfo(refName);
if ( ret.oddSts()) {
refId = ret.id;
refRefId = ret.refid;
refTypeId = ret.typeId;
}
else
refId = 0;
}
public void close(AXtt axtt) {
if ( refRefId != null)
axtt.gdh.unrefObjectInfo(refRefId);
}
@Override
public void scan(AXtt axtt) {
String valueStr = null;
switch ( type) {
case Pwr.eType_Float32: {
float value = axtt.gdh.getObjectRefInfoFloat(refId);
if ( firstScan || value != oldValueF) {
valueStr = "" + value;
oldValueF = value;
}
break;
}
case Pwr.eType_Boolean: {
boolean value = axtt.gdh.getObjectRefInfoBoolean(refId);
if ( firstScan || value != oldValueB) {
valueStr = "" + (int)(value?1:0);
oldValueB = value;
}
break;
}
case Pwr.eType_Int32:
case Pwr.eType_Int16:
case Pwr.eType_Int8:
case Pwr.eType_UInt32:
case Pwr.eType_UInt16:
case Pwr.eType_UInt8: {
int value = axtt.gdh.getObjectRefInfoInt(refId);
if ( firstScan || value != oldValueI) {
valueStr = "" + value;
oldValueI = value;
}
break;
}
case Pwr.eType_String:
case Pwr.eType_AttrRef:
case Pwr.eType_Objid: {
String value = axtt.gdh.getObjectRefInfoString(refId, refTypeId);
if ( firstScan || value.equals(oldValueS)) {
valueStr = "" + value;
oldValueS = value;
valueStr = value;
}
break;
}
}
System.out.println( "Scan value: " + valueStr);
if ( valueStr != null)
node.setAnnotation(1, valueStr, 10);
}
}
package jpwr.app;
import java.util.Vector;
import jpwr.rt.*;
import jpwr.app.*;
public class AXttItemAttrObject extends AXttItemBase {
PwrtObjid objid;
String fullName;
String name;
int flags;
int type;
AXttItemAttrObject(AXtt axtt, PwrtObjid objid, String name, String fullName, int flags, int type,
PlowNode destination, int destCode) {
this.objid = objid;
this.name = name;
this.fullName = fullName;
this.flags = flags;
this.type = type;
node = new PlowNode(axtt.cmn, 0, 0, axtt.ncObject);
node.setAnnotPixmap(0, axtt.iconObject);
node.setAnnotation(0, name, 22);
axtt.cmn.insertNode(node, destination, destCode);
node.setUserData(this);
}
@Override
public void openChildren(AXtt axtt) {
if ( (node.getNodeOpen() & Plow.OPEN_CHILDREN) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_CHILDREN);
node.setAnnotPixmap(0, axtt.iconMap);
}
else {
Vector<GdhrGetXttObj> v = (Vector)axtt.gdh.getAllXttChildren(objid);
for ( int i = 0; i < v.size(); i++) {
GdhrGetXttObj gdhr = v.get(i);
AXttItemObject item = new AXttItemObject(axtt, gdhr.cdhrObjId.objid,
gdhr.fullName, gdhr.hasChildren, node, Plow.DEST_INTOLAST);
}
node.setNodeOpen(Plow.OPEN_CHILDREN);
node.setAnnotPixmap(0, axtt.iconOpenmap);
}
axtt.cmn.configure();
}
@Override
public void openAttributes(AXtt axtt) {
if ( (node.getNodeOpen() & Plow.OPEN_ATTRIBUTES) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_ATTRIBUTES);
}
else if ( (node.getNodeOpen() & Plow.OPEN_CHILDREN) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_CHILDREN);
node.setAnnotPixmap(0, axtt.iconMap);
}
else {
Vector<CdhrObjAttr> v = (Vector)axtt.gdh.getAllClassAttributes(type, objid);
for ( int i = 0; i < v.size(); i++) {
CdhrObjAttr gdhr = v.get(i);
String fName = fullName + "." + gdhr.name;
if ( (gdhr.flags & Pwr.mAdef_pointer) != 0 &&
(gdhr.flags & Pwr.mAdef_private) != 0)
continue;
if ( (gdhr.flags & Pwr.mAdef_array) != 0) {
AXttItemAttrArray item = new AXttItemAttrArray(axtt, gdhr.objid, gdhr.name, fName,
gdhr.flags, gdhr.type, gdhr.elements, node, Plow.DEST_INTOLAST);
}
else if ( (gdhr.flags & Pwr.mAdef_class) != 0) {
AXttItemAttrObject item = new AXttItemAttrObject(axtt, gdhr.objid, gdhr.name, fName,
gdhr.flags, gdhr.type, node, Plow.DEST_INTOLAST);
}
else {
AXttItemAttr item = new AXttItemAttr(axtt, gdhr.objid, gdhr.name, fName,
gdhr.flags, gdhr.type, node, Plow.DEST_INTOLAST);
}
}
node.setNodeOpen(Plow.OPEN_ATTRIBUTES);
}
axtt.cmn.configure();
}
}
package jpwr.app;
import jpwr.rt.*;
public class AXttItemBase {
PlowNode node;
public AXttItemBase() {}
public boolean hasChildren() { return false;}
public void openChildren(AXtt axtt) {}
public void openAttributes(AXtt axtt) {}
public void openCrossreferences(AXtt axtt) {}
public void scan(AXtt axtt) {}
public void close(AXtt axtt) {}
}
package jpwr.app;
import jpwr.rt.PwrtObjid;
public class AXttItemCrr extends AXttItemBase {
String text;
int type;
AXttItemCrr(AXtt axtt, String text, int type, PlowNode destination, int destCode) {
this.text = text;
this.type = type;
node = new PlowNode(axtt.cmn, 0, 0, axtt.ncObject);
switch ( type) {
case AXtt.CRR_READ:
node.setAnnotPixmap(0, axtt.iconCrrRead);
break;
case AXtt.CRR_WRITE:
node.setAnnotPixmap(0, axtt.iconCrrWrite);
break;
case AXtt.CRR_READWRITE:
node.setAnnotPixmap(0, axtt.iconCrrRead);
node.setAnnotPixmap(1, axtt.iconCrrWrite);
break;
}
node.setAnnotation(0, text, 22);
axtt.cmn.insertNode(node, destination, destCode);
node.setUserData(this);
}
public String getText() {
return text;
}
}
package jpwr.app;
import java.util.StringTokenizer;
import java.util.Vector;
import jpwr.rt.*;
import jpwr.app.*;
public class AXttItemObject extends AXttItemBase {
static double y = 10D;
PwrtObjid objid;
PwrtObjid windowObjid;
int classid;
boolean hasChildren;
String fullName;
public AXttItemObject(AXtt axtt, PwrtObjid objid, String fullName, boolean hasChildren,
PlowNode destination, int destCode) {
this.objid = objid;
this.fullName = fullName;
this.hasChildren = hasChildren;
this.windowObjid = null;
CdhrClassId cret = axtt.gdh.getObjectClass(objid);
if (cret.evenSts()) return;
classid = cret.classId;
CdhrObjid coidret = axtt.gdh.classIdToObjid(cret.classId);
if ( coidret.evenSts()) return;
CdhrString cnameret = axtt.gdh.objidToName(coidret.objid, Cdh.mName_object);
if (cnameret.evenSts()) return;
CdhrString ret = axtt.gdh.objidToName(objid, Cdh.mName_object);
if (ret.evenSts()) return;
System.out.println("Item: " + ret.str + " " + cnameret.str);
if ( fullName == null)
fullName = cnameret.str;
if ( classid == Pwrb.cClass_plc) {
coidret = axtt.gdh.getChild(objid);
if ( coidret.oddSts())
windowObjid = coidret.objid;
}
node = new PlowNode(axtt.cmn, 3D, y, axtt.ncObject);
if ( hasChildren)
node.setAnnotPixmap(0, axtt.iconMap);
else
node.setAnnotPixmap(0, axtt.iconLeaf);
node.setAnnotation(0, ret.str, 22);
node.setAnnotation(1, cnameret.str, 11);
axtt.cmn.insertNode(node, destination, destCode);
y += 1.5D;
node.setUserData(this);
}
public int getClassid() {
return classid;
}
public PwrtObjid getObjid() {
return objid;
}
public PwrtObjid getWindowObjid() {
return windowObjid;
}
@Override
public boolean hasChildren() {
return hasChildren;
}
static public void openRoot(AXtt axtt) {
CdhrObjid reto = axtt.gdh.getRootList();
if (reto.oddSts()) {
reto.objid.oix = 0;
Vector<GdhrGetXttObj> v = (Vector)axtt.gdh.getAllXttChildren(reto.objid);
for ( int i = 0; i < v.size(); i++) {
GdhrGetXttObj gdhr = v.get(i);
AXttItemObject item = new AXttItemObject(axtt, gdhr.cdhrObjId.objid,
gdhr.fullName, gdhr.hasChildren, null, Plow.DEST_INTOLAST);
}
}
}
@Override
public void openChildren(AXtt axtt) {
if ( (node.getNodeOpen() & Plow.OPEN_CHILDREN) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_CHILDREN);
node.setAnnotPixmap(0, axtt.iconMap);
}
else if ( (node.getNodeOpen() & Plow.OPEN_ATTRIBUTES) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_ATTRIBUTES);
}
else if ( (node.getNodeOpen() & Plow.OPEN_CROSSREFERENCES) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_CROSSREFERENCES);
}
else {
Vector<GdhrGetXttObj> v = (Vector)axtt.gdh.getAllXttChildren(objid);
for ( int i = 0; i < v.size(); i++) {
GdhrGetXttObj gdhr = v.get(i);
AXttItemObject item = new AXttItemObject(axtt, gdhr.cdhrObjId.objid,
gdhr.fullName, gdhr.hasChildren, node, Plow.DEST_INTOLAST);
}
node.setNodeOpen(Plow.OPEN_CHILDREN);
node.setAnnotPixmap(0, axtt.iconOpenmap);
}
axtt.cmn.configure();
}
@Override
public void openAttributes(AXtt axtt) {
if ( (node.getNodeOpen() & Plow.OPEN_ATTRIBUTES) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_ATTRIBUTES);
}
else if ( (node.getNodeOpen() & Plow.OPEN_CHILDREN) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_CHILDREN);
node.setAnnotPixmap(0, axtt.iconMap);
}
else if ( (node.getNodeOpen() & Plow.OPEN_CROSSREFERENCES) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_CROSSREFERENCES);
}
else {
Vector<CdhrObjAttr> v = (Vector)axtt.gdh.getAllClassAttributes(classid, objid);
for ( int i = 0; i < v.size(); i++) {
CdhrObjAttr gdhr = v.get(i);
String fName = fullName + "." + gdhr.name;
if ( (gdhr.flags & Pwr.mAdef_pointer) != 0 &&
(gdhr.flags & Pwr.mAdef_private) != 0)
continue;
if ( (gdhr.flags & Pwr.mAdef_array) != 0) {
AXttItemAttrArray item = new AXttItemAttrArray(axtt, gdhr.objid, gdhr.name, fName,
gdhr.flags, gdhr.type, gdhr.elements, node, Plow.DEST_INTOLAST);
}
else if ( (gdhr.flags & Pwr.mAdef_class) != 0) {
AXttItemAttrObject item = new AXttItemAttrObject(axtt, gdhr.objid, gdhr.name, fName,
gdhr.flags, gdhr.type, node, Plow.DEST_INTOLAST);
}
else {
AXttItemAttr item = new AXttItemAttr(axtt, gdhr.objid, gdhr.name, fName,
gdhr.flags, gdhr.type, node, Plow.DEST_INTOLAST);
}
}
node.setNodeOpen(Plow.OPEN_ATTRIBUTES);
}
axtt.cmn.configure();
}
public void openCrossreferences(AXtt axtt) {
if ( (node.getNodeOpen() & Plow.OPEN_CROSSREFERENCES) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_CROSSREFERENCES);
}
else {
if ( (node.getNodeOpen() & Plow.OPEN_ATTRIBUTES) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_ATTRIBUTES);
}
else if ( (node.getNodeOpen() & Plow.OPEN_CHILDREN) != 0) {
axtt.cmn.closeNode(node);
node.resetNodeOpen(Plow.OPEN_CHILDREN);
node.setAnnotPixmap(0, axtt.iconMap);
}
CdhrClassId cret = axtt.gdh.getObjectClass( objid);
if ( cret.evenSts()) return;
CdhrString sret;
switch ( cret.classId) {
case Pwrb.cClass_Ai:
case Pwrb.cClass_Ao:
case Pwrb.cClass_Ii:
case Pwrb.cClass_Io:
case Pwrb.cClass_Di:
case Pwrb.cClass_Do:
case Pwrb.cClass_Po:
case Pwrb.cClass_Dv:
case Pwrb.cClass_Av:
case Pwrb.cClass_Iv:
case Pwrb.cClass_Sv:
sret = axtt.gdh.crrSignal( fullName);
break;
default:
sret = axtt.gdh.crrObject( fullName);
}
if ( sret.evenSts()) return;
String delim = new String( new char[] { '\n'});
StringTokenizer tokens = new StringTokenizer( sret.str, delim);
int tokensCnt = tokens.countTokens();
String text;
int type;
for ( int i = 0; i < tokensCnt; i++) {
String token = tokens.nextToken();
text = token.substring(1);
if ( token.startsWith("0"))
type = AXtt.CRR_READ;
else if ( token.startsWith("1"))
type = AXtt.CRR_WRITE;
else
type = AXtt.CRR_READWRITE;
AXttItemCrr item = new AXttItemCrr(axtt, text, type, node, Plow.DEST_INTOLAST);
}
node.setNodeOpen(Plow.OPEN_CROSSREFERENCES);
}
}
}
/*
* 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.app;
import jpwr.rt.PwrtObjid;
public class Flow {
public static final int DRAWOFFSET = 2;
public static final int eObjectType_NoObject = 0;
public static final int eObjectType_Node = 1;
public static final int eObjectType_Con = 2;
public static final int eObjectType_Rect = 3;
public static final int eObjectType_Line = 4;
public static final int eObjectType_Arc = 5;
public static final int eObjectType_Text = 6;
public static final int eObjectType_ConPoint = 7;
public static final int eObjectType_Annot = 8;
public static final int eObjectType_NodeClass = 9;
public static final int eObjectType_ConClass = 10;
public static final int eObjectType_Arrow = 11;
public static final int eObjectType_Pixmap = 12;
public static final int eObjectType_AnnotPixmap = 13;
public static final int eObjectType_Radiobutton = 14;
public static final int eObjectType_Frame = 15;
public static final int eObjectType_Image = 16;
public static final int eConType_Straight = 0;
public static final int eConType_Fixed = 1;
public static final int eConType_AllFixed = 2;
public static final int eConType_Routed = 3;
public static final int eConType_StepDiv = 4;
public static final int eConType_StepConv = 5;
public static final int eConType_TransDiv = 6;
public static final int eConType_TransConv = 7;
public static final int eConType_StraightOneArrow = 8;
public static final int eConType_Reference = 9;
public static final int eDrawType_Line = 0;
public static final int eDrawType_LineRed = 1;
public static final int eDrawType_LineGray = 2;
public static final int eDrawType_LineErase = 3;
public static final int eDrawType_LineDashed = 4;
public static final int eDrawType_LineDashedRed = 5;
public static final int eDrawType_TextHelvetica = 6;
public static final int eDrawType_TextHelveticaBold = 7;
public static final int eDrawType_TextHelveticaErase = 8;
public static final int eDrawType_TextHelveticaEraseBold = 9;
public static final int mDisplayLevel_1 = 1 << 0;
public static final int mDisplayLevel_2 = 1 << 2;
public static final int mDisplayLevel_3 = 1 << 3;
public static final int mDisplayLevel_4 = 1 << 4;
public static final int mDisplayLevel_5 = 1 << 5;
public static final int mDisplayLevel_6 = 1 << 6;
public static final int eNodeGroup_Common = 0;
public static final int eNodeGroup_Document = 1;
public static final int eNodeGroup_Trace = 2;
public static final int eTraceType_Boolean = 0;
public static final int eTraceType_Int32 = 1;
public static final int eTraceType_Float32 = 2;
public static final int eTraceType_User = 3;
public static final int eSave_Ctx = 1;
public static final int eSave_Array = 2;
public static final int eSave_NodeClass = 3;
public static final int eSave_ConClass = 4;
public static final int eSave_Rect = 5;
public static final int eSave_Line = 6;
public static final int eSave_Point = 7;
public static final int eSave_Arc = 8;
public static final int eSave_Text = 9;
public static final int eSave_Node = 10;
public static final int eSave_Con = 11;
public static final int eSave_ConPoint = 12;
public static final int eSave_Annot = 13;
public static final int eSave_Arrow = 14;
public static final int eSave_Pixmap = 15;
public static final int eSave_AnnotPixmap = 16;
public static final int eSave_Radiobutton = 17;
public static final int eSave_Frame = 18;
public static final int eSave_End = 99;
public static final int eSave_Ctx_zoom_factor = 100;
public static final int eSave_Ctx_base_zoom_factor = 101;
public static final int eSave_Ctx_offset_x = 102;
public static final int eSave_Ctx_offset_y = 103;
public static final int eSave_Ctx_nav_zoom_factor = 104;
public static final int eSave_Ctx_print_zoom_factor = 105;
public static final int eSave_Ctx_nav_offset_x = 106;
public static final int eSave_Ctx_nav_offset_y = 107;
public static final int eSave_Ctx_x_right = 108;
public static final int eSave_Ctx_x_left = 109;
public static final int eSave_Ctx_y_high = 110;
public static final int eSave_Ctx_y_low = 111;
public static final int eSave_Ctx_window_width = 112;
public static final int eSave_Ctx_window_height = 113;
public static final int eSave_Ctx_nav_window_width = 114;
public static final int eSave_Ctx_nav_window_height = 115;
public static final int eSave_Ctx_nav_rect_ll_x = 116;
public static final int eSave_Ctx_nav_rect_ll_y = 117;
public static final int eSave_Ctx_nav_rect_ur_x = 118;
public static final int eSave_Ctx_nav_rect_ur_y = 119;
public static final int eSave_Ctx_nav_rect_hot = 120;
public static final int eSave_Ctx_name = 121;
public static final int eSave_Ctx_user_highlight = 122;
public static final int eSave_Ctx_a_nc = 123;
public static final int eSave_Ctx_a_cc = 124;
public static final int eSave_Ctx_a = 125;
public static final int eSave_Ctx_grid_size_x = 126;
public static final int eSave_Ctx_grid_size_y = 127;
public static final int eSave_Ctx_grid_on = 128;
public static final int eSave_Ctx_draw_delta = 129;
public static final int eSave_Ctx_refcon_width = 130;
public static final int eSave_Ctx_refcon_height = 131;
public static final int eSave_Ctx_refcon_textsize = 132;
public static final int eSave_Ctx_refcon_linewidth = 133;
public static final int eSave_Array_a = 200;
public static final int eSave_NodeClass_nc_name = 300;
public static final int eSave_NodeClass_a = 301;
public static final int eSave_NodeClass_group = 302;
public static final int eSave_NodeClass_no_con_obstacle = 303;
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;
public static final int eSave_ConClass_draw_type = 403;
public static final int eSave_ConClass_line_width = 404;
public static final int eSave_ConClass_arrow_width = 405;
public static final int eSave_ConClass_arrow_length = 406;
public static final int eSave_ConClass_round_corner_amount = 407;
public static final int eSave_ConClass_group = 408;
public static final int eSave_Rect_draw_type = 500;
public static final int eSave_Rect_line_width = 501;
public static final int eSave_Rect_ll = 502;
public static final int eSave_Rect_ur = 503;
public static final int eSave_Rect_display_level = 504;
public static final int eSave_Line_draw_type = 600;
public static final int eSave_Line_line_width = 601;
public static final int eSave_Line_p1 = 602;
public static final int eSave_Line_p2 = 603;
public static final int eSave_Point_x = 700;
public static final int eSave_Point_y = 701;
public static final int eSave_Arc_angel1 = 800;
public static final int eSave_Arc_angel2 = 801;
public static final int eSave_Arc_draw_type = 802;
public static final int eSave_Arc_line_width = 803;
public static final int eSave_Arc_ll = 804;
public static final int eSave_Arc_ur = 805;
public static final int eSave_Text_text_size = 900;
public static final int eSave_Text_draw_type = 901;
public static final int eSave_Text_text = 902;
public static final int eSave_Text_p = 903;
public static final int eSave_Node_nc = 1000;
public static final int eSave_Node_pos = 1001;
public static final int eSave_Node_n_name = 1002;
public static final int eSave_Node_annotsize = 1003;
public static final int eSave_Node_annotv = 1004;
public static final int eSave_Node_refcon_cnt = 1005;
public static final int eSave_Node_x_right = 1006;
public static final int eSave_Node_x_left = 1007;
public static final int eSave_Node_y_high = 1008;
public static final int eSave_Node_y_low = 1009;
public static final int eSave_Node_trace_object = 1010;
public static final int eSave_Node_trace_attribute = 1011;
public static final int eSave_Node_trace_attr_type = 1012;
public static final int eSave_Node_obst_x_right = 1013;
public static final int eSave_Node_obst_x_left = 1014;
public static final int eSave_Node_obst_y_high = 1015;
public static final int eSave_Node_obst_y_low = 1016;
public static final int eSave_Node_trace_inverted = 1017;
public static final int eSave_Con_x_right = 1100;
public static final int eSave_Con_x_left = 1101;
public static final int eSave_Con_y_high = 1102;
public static final int eSave_Con_y_low = 1103;
public static final int eSave_Con_cc = 1104;
public static final int eSave_Con_dest_node = 1105;
public static final int eSave_Con_source_node = 1106;
public static final int eSave_Con_dest_conpoint = 1107;
public static final int eSave_Con_source_conpoint = 1108;
public static final int eSave_Con_dest_direction = 1109;
public static final int eSave_Con_source_direction = 1110;
public static final int eSave_Con_line_a = 1111;
public static final int eSave_Con_arc_a = 1112;
public static final int eSave_Con_arrow_a = 1113;
public static final int eSave_Con_ref_a = 1114;
public static final int eSave_Con_p_num = 1115;
public static final int eSave_Con_l_num = 1116;
public static final int eSave_Con_a_num = 1117;
public static final int eSave_Con_arrow_num = 1118;
public static final int eSave_Con_ref_num = 1119;
public static final int eSave_Con_point_x = 1120;
public static final int eSave_Con_point_y = 1121;
public static final int eSave_Con_source_ref_cnt = 1122;
public static final int eSave_Con_dest_ref_cnt = 1123;
public static final int eSave_Con_c_name = 1124;
public static final int eSave_Con_trace_object = 1125;
public static final int eSave_Con_trace_attribute = 1126;
public static final int eSave_Con_trace_attr_type = 1127;
public static final int eSave_Con_temporary_ref = 1128;
public static final int eSave_ConPoint_number = 1200;
public static final int eSave_ConPoint_direction = 1201;
public static final int eSave_ConPoint_p = 1202;
public static final int eSave_ConPoint_trace_attribute = 1203;
public static final int eSave_ConPoint_trace_attr_type = 1204;
public static final int eSave_Annot_number = 1300;
public static final int eSave_Annot_draw_type = 1301;
public static final int eSave_Annot_text_size = 1302;
public static final int eSave_Annot_p = 1303;
public static final int eSave_Annot_annot_type = 1304;
public static final int eSave_Annot_display_level = 1305;
public static final int eSave_Arrow_arrow_width = 1400;
public static final int eSave_Arrow_arrow_length = 1401;
public static final int eSave_Arrow_draw_type = 1402;
public static final int eSave_Arrow_line_width = 1403;
public static final int eSave_Arrow_p_dest = 1404;
public static final int eSave_Arrow_p1 = 1405;
public static final int eSave_Arrow_p2 = 1406;
public static String getFileName(PwrtObjid oid) {
String filename = "pwr_" +
String.format("%03d", oid.vid / 16777216) + "_" +
String.format("%03d", (oid.vid / 65536) & 0xFF) + "_" +
String.format("%03d", (oid.vid / 256) & 0xFF) + "_" +
String.format("%03d", oid.vid & 0xFF) + "_" +
String.format("%08x", oid.oix) + ".flw";
return filename;
}
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowAnnot implements FlowArrayElem {
FlowPoint p;
int draw_type;
int text_size;
int display_level;
int annot_type;
int number;
FlowCmn cmn;
public FlowAnnot( FlowCmn cmn) {
this.cmn = cmn;
p = new FlowPoint(cmn);
}
@Override
public int type() {
return Flow.eObjectType_Annot;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_Annot:
break;
case Flow.eSave_Annot_number:
number = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Annot_draw_type:
draw_type = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Annot_text_size:
text_size = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Annot_display_level:
display_level = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Annot_p:
p.open( reader);
break;
case Flow.eSave_Annot_annot_type:
annot_type = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowAnnot");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowAnnot");
}
}
public void draw( FlowPoint p0, String[] annotv, boolean highlight) {
if ( annotv == null || annotv[number] == null)
return;
if ( (display_level & FlowCmn.display_level) == 0)
return;
int tsize;
int idx = (int) (cmn.zoom_factor/cmn.base_zoom_factor * text_size * 5.8 + 1.0);
if ( cmn.zoom_factor/cmn.base_zoom_factor * text_size * 6.5 < 2) return;
int color = Flow.eDrawType_Line;
if ( highlight)
color = Flow.eDrawType_LineRed;
cmn.gdraw.drawText( annotv[number], color, idx, 0, (float)((p.x + p0.x) * cmn.zoom_factor - cmn.offset_x),
(float)((p.y + p0.y) * cmn.zoom_factor - cmn.offset_y));
// if ( idx > 8)
// idx = 8;
/*
switch( idx) {
case 0: tsize = 8; break;
case 1: tsize = 10; break;
case 2: tsize = 12; break;
case 3: tsize = 14; break;
case 4: tsize = 14; break;
case 5: tsize = 18; break;
case 6: tsize = 18; break;
case 7: tsize = 18; break;
default: tsize = idx * 3;
}
tsize -= tsize/5;
Font f;
switch ( draw_type) {
case Flow.eDrawType_TextHelveticaBold:
f = new Font("Helvetica", Font.BOLD, tsize);
break;
default:
f = new Font("Helvetica", Font.PLAIN, tsize);
}
char[] c = new char[] { 10 };
StringTokenizer token = new StringTokenizer( annotv[number], new String(c));
g.setColor( Color.black);
if ( highlight)
g.setColor( Color.red);
g.setFont( f);
float x = (float)((p.x + p0.x) * cmn.zoom_factor);
float y = (float)((p.y + p0.y) * cmn.zoom_factor - tsize/4);
while ( token.hasMoreTokens()) {
g.drawString( token.nextToken(), x, y);
y += f.getSize2D() * 1.4;
}
*/
}
@Override
public boolean getSelect() {
return false;
}
@Override
public void setSelect(boolean select) {
}
public boolean eventHandler(PlowEvent e) {
return false;
}
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowArc implements FlowArrayElem {
FlowPoint ll;
FlowPoint ur;
double angel1;
double angel2;
int draw_type;
int line_width;
FlowCmn cmn;
public FlowArc( FlowCmn cmn) {
this.cmn = cmn;
ll = new FlowPoint(cmn);
ur = new FlowPoint(cmn);
}
@Override
public int type() {
return Flow.eObjectType_Arc;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_Arc:
break;
case Flow.eSave_Arc_draw_type:
draw_type = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Arc_line_width:
line_width = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Arc_angel1:
angel1 = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Arc_angel2:
angel2 = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Arc_ll:
ll.open( reader);
break;
case Flow.eSave_Arc_ur:
ur.open( reader);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowArc");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowArc");
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
int color;
switch ( draw_type) {
case Flow.eDrawType_LineGray:
color = Plow.COLOR_LIGHTGRAY;
break;
case Flow.eDrawType_LineRed:
case Flow.eDrawType_LineDashedRed:
color = Plow.COLOR_RED;
break;
default:
color = Plow.COLOR_BLACK;
}
if ( highlight)
color = Plow.COLOR_RED;
cmn.gdraw.arc( true, color, (float)((ll.x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((ll.y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)((ur.x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((ur.y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)angel1, (float)angel2);
/*
Arc2D.Double rect = new Arc2D.Double( (ll.x + p.x) * cmn.zoom_factor,
(ll.y + p.y) * cmn.zoom_factor,
(ur.x - ll.x) * cmn.zoom_factor,
(ur.y - ll.y) * cmn.zoom_factor,
angel1, angel2, Arc2D.OPEN);
g.setStroke( new BasicStroke( (float)(cmn.zoom_factor / cmn.base_zoom_factor * line_width)));
g.setColor( Color.black);
if ( highlight)
g.setColor( Color.red);
g.draw( rect);
*/
}
@Override
public boolean getSelect() {
return false;
}
@Override
public void setSelect(boolean select) {
}
public boolean eventHandler(PlowEvent e) {
return false;
}
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowArray {
Vector a = new Vector();
FlowCmn cmn;
public FlowArray( FlowCmn cmn) {
this.cmn = cmn;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_Array:
break;
case Flow.eSave_Rect:
FlowRect rect = new FlowRect( cmn);
rect.open( reader);
a.add( rect);
break;
case Flow.eSave_Line:
FlowLine l = new FlowLine( cmn);
l.open( reader);
a.add( l);
break;
case Flow.eSave_Arc:
FlowArc arc = new FlowArc( cmn);
arc.open( reader);
a.add( arc);
break;
case Flow.eSave_Text:
FlowText text = new FlowText( cmn);
text.open( reader);
a.add( text);
break;
case Flow.eSave_ConPoint:
FlowConPoint cp = new FlowConPoint( cmn);
cp.open( reader);
a.add( cp);
break;
case Flow.eSave_Annot:
FlowAnnot annot = new FlowAnnot( cmn);
annot.open( reader);
a.add( annot);
break;
case Flow.eSave_Arrow:
FlowArrow arrow = new FlowArrow( cmn);
arrow.open( reader);
a.add( arrow);
break;
case Flow.eSave_Point:
FlowPoint point = new FlowPoint( cmn);
point.open( reader);
a.add( point);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowArray");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowArray");
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
for ( int i = 0; i < a.size(); i++) {
((FlowArrayElem)a.get(i)).draw( p, annotv, highlight);
}
}
public void draw( FlowPoint p, int size, boolean highlight) {
for ( int i = 0; i < size; i++) {
((FlowArrayElem)a.get(i)).draw( p, null, highlight);
}
}
public boolean eventHandler(PlowEvent e) {
for ( int i = 0; i < a.size(); i++) {
if ( ((FlowArrayElem)a.get(i)).eventHandler(e))
return true;
}
return false;
}
}
/*
* 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.app;
public interface FlowArrayElem {
public void draw( FlowPoint p, String[] annotv, boolean highlight);
public boolean getSelect();
public void setSelect(boolean select);
public boolean eventHandler(PlowEvent e);
public int type();
}
/*
* 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.app;
import java.io.*;
import java.util.*;
import android.graphics.Path;
public class FlowArrow implements FlowArrayElem {
FlowPoint p1;
FlowPoint p2;
FlowPoint p_dest;
double arrow_width;
double arrow_length;
int draw_type;
int line_width;
FlowCmn cmn;
public FlowArrow( FlowCmn cmn) {
this.cmn = cmn;
p1 = new FlowPoint(cmn);
p2 = new FlowPoint(cmn);
p_dest = new FlowPoint(cmn);
}
@Override
public int type() {
return Flow.eObjectType_Arrow;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_Arrow:
break;
case Flow.eSave_Arrow_arrow_width:
arrow_width = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Arrow_arrow_length:
arrow_length = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Arrow_draw_type:
draw_type = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Arrow_line_width:
line_width = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Arrow_p_dest:
p_dest.open( reader);
break;
case Flow.eSave_Arrow_p1:
p1.open( reader);
break;
case Flow.eSave_Arrow_p2:
p2.open( reader);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowArrow");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowArrow");
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
int color;
Path path = new Path();
switch ( draw_type) {
case Flow.eDrawType_LineGray:
color = Plow.COLOR_LIGHTGRAY;
break;
case Flow.eDrawType_LineRed:
case Flow.eDrawType_LineDashedRed:
color = Plow.COLOR_RED;
break;
default:
color = Plow.COLOR_BLACK;
}
if ( highlight)
color = Plow.COLOR_RED;
cmn.gdraw.arrow(color, (float)((p1.x + p.x) * cmn.zoom_factor - cmn.offset_x), (float)((p1.y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)((p2.x + p.x) * cmn.zoom_factor - cmn.offset_x), (float)((p2.y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)((p_dest.x + p.x) * cmn.zoom_factor - cmn.offset_x), (float)((p_dest.y + p.y) * cmn.zoom_factor - cmn.offset_y));
}
@Override
public boolean getSelect() {
return false;
}
@Override
public void setSelect(boolean select) {
}
public boolean eventHandler(PlowEvent e) {
return false;
}
}
/*
* 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.app;
import jpwr.rt.*;
import java.io.*;
import java.util.*;
import android.graphics.Canvas;
import android.view.MotionEvent;
public class FlowCmn implements PlowCmnIfc {
PwrtObjid objid;
static final int display_level = Flow.mDisplayLevel_1;
static final int scrollOffset = 200;
boolean debug;
boolean antiAliasing;
PlowAppl appl;
Gdh gdh;
double zoom_factor;
double base_zoom_factor;
int offset_x;
int offset_y;
double x_right;
double x_left;
double y_high;
double y_low;
PlowDrawIfc gdraw;
// Canvas canvas;
int canvasWidth;
int canvasHeight;
FlowNode currentNode;
FlowNode selectedNode;
boolean opened = false;
Object userData;
Vector<FlowArrayElem> a = new Vector<FlowArrayElem>();
Vector<FlowArrayElem> a_nc = new Vector<FlowArrayElem>();
Vector<FlowArrayElem> a_cc = new Vector<FlowArrayElem>();
public FlowCmn( PlowAppl appl, Gdh gdh, PwrtObjid objid) {
this.gdh = gdh;
this.objid = objid;
this.appl = appl;
this.debug = false;
this.antiAliasing = true;
currentNode = null;
selectedNode = null;
}
@Override
public int type() {
return PlowCmnIfc.TYPE_FLOW;
}
public PwrtObjid getObjid() {
return objid;
}
public void setGDraw(PlowDrawIfc gdraw) {
this.gdraw = gdraw;
canvasWidth = gdraw.getCanvasWidth();
canvasHeight = gdraw.getCanvasHeight();
}
public void draw() {
for ( int i = 0; i < a.size(); i++) {
a.get(i).draw(new FlowPoint(this), null, false);
}
}
@Override
public void zoom(double factor) {
zoom_factor *= factor;
draw();
}
@Override
public void scroll( int x, int y) {
offset_y += y;
offset_x += x;
if ( offset_x < x_left * zoom_factor - scrollOffset)
offset_x = (int)(x_left * zoom_factor) - scrollOffset;
if ( offset_x > x_right * zoom_factor - canvasWidth + scrollOffset)
offset_x = (int)(x_right * zoom_factor - canvasWidth) + scrollOffset;
if ( offset_y < y_low * zoom_factor - scrollOffset)
offset_y = (int)(y_low * zoom_factor) - scrollOffset;
if ( offset_y > y_high * zoom_factor - canvasHeight + 80 + scrollOffset)
offset_y = (int)(y_high * zoom_factor - canvasHeight + 80) + scrollOffset;
}
@Override
public void pageUp() {
offset_y -= canvasHeight * 0.8;
if ( offset_y < y_low * zoom_factor)
offset_y = (int)(y_low * zoom_factor);
}
@Override
public void pageDown() {
offset_y += canvasHeight * 0.8;
if ( offset_y > y_high * zoom_factor - canvasHeight + 80)
offset_y = (int)(y_high * zoom_factor - canvasHeight + 80);
}
@Override
public void eventHandler(int action, double fx, double fy) {
double x = (fx + offset_x) / zoom_factor;
double y = (fy + offset_y) / zoom_factor;
int type;
switch( action) {
case MotionEvent.ACTION_UP:
type = PlowEvent.TYPE_CLICK;
break;
default:
return;
}
System.out.println("Event: " + type + "(" + x + "," + y + ")");
PlowEvent e = new PlowEvent(type, x, y, null);
currentNode = null;
for ( int i = 0; i < a.size(); i++) {
if ( a.get(i).eventHandler(e))
break;
}
appl.eventHandler(e);
switch (e.type) {
case PlowEvent.TYPE_OBJECT_DELETED:
if ( currentNode == selectedNode)
selectedNode = null;
break;
}
}
@Override
public void select(Object node) {
selectedNode = (FlowNode)node;
}
@Override
public void selectClear() {
selectedNode = null;
}
@Override
public Object getSelect() {
return selectedNode;
}
public void centerObject(FlowArrayElem object) {
if ( object.type() == Flow.eObjectType_Node) {
FlowDimension d = ((FlowNode)object).measureNode();
int x = (int)((d.x1 + d.x2) / 2 * zoom_factor - canvasWidth / 2);
int y = (int)((d.y1 + d.y2) / 2 * zoom_factor - canvasHeight / 2);
scroll(x - offset_x, y - offset_y);
draw();
}
}
public void dynamicOpen() {
System.out.println("FlowCmn::dynamicOpen");
for ( int i = 0; i < a.size(); i++) {
if ( a.get(i).type() == Flow.eObjectType_Node)
((FlowNode)a.get(i)).dynamicOpen();
}
opened = true;
}
public void dynamicClose() {
for ( int i = 0; i < a.size(); i++) {
if ( a.get(i).type() == Flow.eObjectType_Node)
((FlowNode)a.get(i)).dynamicClose();
}
}
public void dynamicUpdate() {
if (!opened)
return;
System.out.println("FlowCmn::dynamicUpdate");
for ( int i = 0; i < a.size(); i++) {
if ( a.get(i).type() == Flow.eObjectType_Node)
((FlowNode)a.get(i)).dynamicUpdate(false);
}
}
public void configure() {}
public Object getUserData() {
return userData;
}
public void setUserData(Object userData) {
this.userData = userData;
}
public void setCanvas(Canvas canvas) {
gdraw.setCanvas(canvas);
}
public Object getFirst() {
return null;
}
public Object getLast() {
return null;
}
public Object getNext(Object elem) {
return null;
}
public Object getPrevious(Object elem) {
return null;
}
public int remove(Object e) {
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.app;
import java.io.*;
import java.util.*;
public class FlowCon implements FlowArrayElem {
double x_right;
double x_left;
double y_high;
double y_low;
FlowCmn cmn;
FlowConClass cc;
int p_num;
int l_num;
int a_num;
int arrow_num;
int ref_num;
double point_x[] = new double[8];
double point_y[] = new double[8];
FlowArray line_a;
FlowArray arc_a;
FlowArray arrow_a;
FlowArray ref_a;
String c_name;
String trace_object;
String trace_attribute;
int trace_attr_type;
int temporary_ref;
boolean highlight;
FlowCon( FlowCmn cmn) {
this.cmn = cmn;
line_a = new FlowArray(cmn);
arc_a = new FlowArray(cmn);
arrow_a = new FlowArray(cmn);
ref_a = new FlowArray(cmn);
}
@Override
public int type() {
return Flow.eObjectType_Con;
}
public String getName() {
return c_name;
}
public String getTraceObject() {
return trace_object;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
int i;
boolean 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( "line : " + key);
switch ( key) {
case Flow.eSave_Con:
break;
case Flow.eSave_Con_cc:
String cc_name = token.nextToken();
found = false;
for ( i = 0; i < cmn.a_cc.size(); i++) {
if ( ((FlowConClass)cmn.a_cc.get(i)).cc_name.equals( cc_name)) {
cc = (FlowConClass) cmn.a_cc.get(i);
found = true;
break;
}
}
if ( !found)
System.out.println( "FlowCon: ConClass not found: " + cc_name);
break;
case Flow.eSave_Con_c_name:
if ( token.hasMoreTokens())
c_name = token.nextToken();
else
c_name = new String();
break;
case Flow.eSave_Con_x_right:
x_right = new Double( token.nextToken()).doubleValue();
break;
case Flow.eSave_Con_x_left:
x_left = new Double( token.nextToken()).doubleValue();
break;
case Flow.eSave_Con_y_high:
y_high = new Double( token.nextToken()).doubleValue();
break;
case Flow.eSave_Con_y_low:
y_low = new Double( token.nextToken()).doubleValue();
break;
case Flow.eSave_Con_dest_node:
reader.readLine();
break;
case Flow.eSave_Con_source_node:
reader.readLine();
break;
case Flow.eSave_Con_dest_conpoint:
case Flow.eSave_Con_source_conpoint:
case Flow.eSave_Con_dest_direction:
case Flow.eSave_Con_source_direction:
break;
case Flow.eSave_Con_line_a:
line_a.open( reader);
break;
case Flow.eSave_Con_arc_a:
arc_a.open( reader);
break;
case Flow.eSave_Con_arrow_a:
arrow_a.open( reader);
break;
case Flow.eSave_Con_ref_a:
ref_a.open( reader);
break;
case Flow.eSave_Con_p_num:
p_num = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Con_l_num:
l_num = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Con_a_num:
a_num = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Con_arrow_num:
arrow_num = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Con_ref_num:
ref_num = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Con_point_x:
for ( i = 0; i < p_num; i++)
point_x[i] = new Double( reader.readLine()).doubleValue();
break;
case Flow.eSave_Con_point_y:
for ( i = 0; i < p_num; i++)
point_y[i] = new Double( reader.readLine()).doubleValue();
break;
case Flow.eSave_Con_source_ref_cnt:
case Flow.eSave_Con_dest_ref_cnt:
break;
case Flow.eSave_Con_trace_object:
if ( token.hasMoreTokens())
trace_object = token.nextToken();
break;
case Flow.eSave_Con_trace_attribute:
if ( token.hasMoreTokens())
trace_attribute = token.nextToken();
break;
case Flow.eSave_Con_trace_attr_type:
trace_attr_type = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Con_temporary_ref:
temporary_ref = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowCon");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowCon");
}
}
public void setBounds() {
// Make extra space for arrows witch is not included in rectangel
int x = (int)((x_left - cmn.x_left) * cmn.zoom_factor) - 3 * Flow.DRAWOFFSET;
int y = (int)((y_low - cmn.y_low) * cmn.zoom_factor) - 3 * Flow.DRAWOFFSET;
int width = (int)((x_right - x_left) * cmn.zoom_factor) + 6 * Flow.DRAWOFFSET;
int height = (int)((y_high - y_low) * cmn.zoom_factor) + 6 * Flow.DRAWOFFSET;
// setBounds( x, y, width, height);
}
public boolean getSelect() {
return false;
}
public void setSelect( boolean select) {
}
public void draw( FlowPoint p0, String[] annotv, boolean highlight) {
// Adjust pos to javabean koordinates
FlowPoint p = new FlowPoint(cmn);
p.x = x_left / cmn.zoom_factor;
p.y = y_low / cmn.zoom_factor;
if ( temporary_ref != 0 || cc.con_type == Flow.eConType_Reference)
ref_a.draw( p, null, highlight);
else {
line_a.draw( p, l_num, highlight);
arc_a.draw( p, a_num, highlight);
arrow_a.draw( p, arrow_num, highlight);
}
}
public boolean eventHandler(PlowEvent e) {
return false;
}
/*
public void paintComponent( Graphics g1) {
Graphics2D g = (Graphics2D) g1;
if ( cmn.antiAliasing)
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
// Adjust pos to javabean koordinates
FlowPoint p = new FlowPoint(cmn);
p.x = - x_left + ((double) (3 * Flow.DRAWOFFSET)) / cmn.zoom_factor;
p.y = - y_low + ((double) ( 3 * Flow.DRAWOFFSET)) / cmn.zoom_factor;
if ( temporary_ref != 0 || cc.con_type == Flow.eConType_Reference)
ref_a.draw( g, p, null, highlight);
else {
line_a.draw( g, p, l_num, highlight);
arc_a.draw( g, p, a_num, highlight);
arrow_a.draw( g, p, arrow_num, highlight);
}
}
*/
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowConClass {
String cc_name;
int con_type;
int corner;
int draw_type;
int line_width;
double arrow_width;
double arrow_length;
double round_corner_amount;
int group;
FlowCmn cmn;
public FlowConClass( FlowCmn cmn) {
this.cmn = cmn;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_ConClass:
break;
case Flow.eSave_ConClass_cc_name:
cc_name = token.nextToken();
break;
case Flow.eSave_ConClass_con_type:
con_type = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_ConClass_corner:
corner = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_ConClass_draw_type:
draw_type = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_ConClass_line_width:
line_width = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_ConClass_arrow_width:
arrow_width = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_ConClass_arrow_length:
arrow_length = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_ConClass_round_corner_amount:
round_corner_amount = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_ConClass_group:
group = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowConClass");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowConClass");
}
}
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowConPoint implements FlowArrayElem {
FlowPoint p;
int number;
int direction;
String trace_attribute;
int trace_attr_type;
FlowCmn cmn;
public FlowConPoint( FlowCmn cmn) {
this.cmn = cmn;
p = new FlowPoint(cmn);
}
@Override
public int type() {
return Flow.eObjectType_ConPoint;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_ConPoint:
break;
case Flow.eSave_ConPoint_number:
number = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_ConPoint_direction:
direction = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_ConPoint_p:
p.open( reader);
break;
case Flow.eSave_ConPoint_trace_attribute:
trace_attribute = reader.readLine();
break;
case Flow.eSave_ConPoint_trace_attr_type:
trace_attr_type = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowConPoint");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowConPoint");
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
}
@Override
public boolean getSelect() {
return false;
}
@Override
public void setSelect(boolean select) {
}
public boolean eventHandler(PlowEvent e) {
return false;
}
}
/*
* 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.app;
import java.io.*;
import java.util.*;
import jpwr.rt.*;
public class FlowCtx implements FlowCtxInterface {
FlowCmn cmn;
String name;
public FlowCtx( FlowCmn cmn) {
this.cmn = cmn;
}
public void unselect() {
/*
for ( int i = 0; i < cmn.a.size(); i++)
((FlowComponent)cmn.a.get(i)).setSelect( false);
*/
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_Ctx:
break;
case Flow.eSave_Ctx_zoom_factor:
cmn.zoom_factor = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Ctx_base_zoom_factor:
cmn.base_zoom_factor = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Ctx_offset_x:
cmn.offset_x = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Ctx_offset_y:
cmn.offset_y = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Ctx_nav_zoom_factor:
case Flow.eSave_Ctx_print_zoom_factor:
case Flow.eSave_Ctx_nav_offset_x:
case Flow.eSave_Ctx_nav_offset_y:
break;
case Flow.eSave_Ctx_x_right:
cmn.x_right = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Ctx_x_left:
cmn.x_left = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Ctx_y_high:
cmn.y_high = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Ctx_y_low:
cmn.y_low = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Ctx_nav_rect_ll_x:
case Flow.eSave_Ctx_nav_rect_ll_y:
case Flow.eSave_Ctx_nav_rect_ur_x:
case Flow.eSave_Ctx_nav_rect_ur_y:
case Flow.eSave_Ctx_nav_rect_hot:
break;
case Flow.eSave_Ctx_name:
name = token.nextToken();
break;
case Flow.eSave_Ctx_user_highlight:
case Flow.eSave_Ctx_grid_size_x:
case Flow.eSave_Ctx_grid_size_y:
case Flow.eSave_Ctx_grid_on:
case Flow.eSave_Ctx_draw_delta:
case Flow.eSave_Ctx_refcon_width:
case Flow.eSave_Ctx_refcon_height:
case Flow.eSave_Ctx_refcon_textsize:
case Flow.eSave_Ctx_refcon_linewidth:
break;
case Flow.eSave_Ctx_a_nc:
FlowVector.open( reader, cmn, cmn.a_nc);
break;
case Flow.eSave_Ctx_a_cc:
FlowVector.open( reader, cmn, cmn.a_cc);
break;
case Flow.eSave_Ctx_a:
FlowVector.open( reader, cmn, cmn.a);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowCtx");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowCtx");
}
//cmn.base_zoom_factor /= 5F;
cmn.zoom_factor = cmn.base_zoom_factor;
}
public Object getSelected() {
for ( int i = 0; i < cmn.a.size(); i++) {
if ( ((FlowArrayElem)cmn.a.get(i)).getSelect())
return cmn.a.get(i);
}
return null;
}
public Object getObject( String name) {
for ( int i = 0; i < cmn.a.size(); i++) {
if ( ((FlowArrayElem)cmn.a.get(i)).type() == Flow.eObjectType_Node) {
if ( ((FlowNode)cmn.a.get(i)).getName().equalsIgnoreCase( name))
return cmn.a.get(i);
}
}
return null;
}
public void centerObject(FlowArrayElem object) {
cmn.centerObject(object);
}
}
/*
* 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.app;
public interface FlowCtxInterface {
public void unselect();
}
package jpwr.app;
public class FlowDimension {
double x1, y1, x2, y2;
public FlowDimension(double x1, double y1, double x2, double y2) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
}
package jpwr.app;
public interface FlowDrawIfc {
public void rect(boolean border, int color, float x, float y, float width, float height);
public void pixmap(PlowPixmapData pixmapData, int idx, boolean invert, float x, float y);
public void drawText( String text, int textColor, int textSize, int font, float x, float y);
public float measureText( String text, int textSize, int font);
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowLine implements FlowArrayElem {
FlowPoint p1;
FlowPoint p2;
int draw_type;
int line_width;
FlowCmn cmn;
public FlowLine( FlowCmn cmn) {
this.cmn = cmn;
p1 = new FlowPoint(cmn);
p2 = new FlowPoint(cmn);
}
@Override
public int type() {
return Flow.eObjectType_Line;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_Line:
break;
case Flow.eSave_Line_draw_type:
draw_type = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Line_line_width:
line_width = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Line_p1:
p1.open( reader);
break;
case Flow.eSave_Line_p2:
p2.open( reader);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowLine");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowLine");
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
int color;
switch ( draw_type) {
case Flow.eDrawType_LineGray:
color = Plow.COLOR_LIGHTGRAY;
break;
case Flow.eDrawType_LineRed:
case Flow.eDrawType_LineDashedRed:
color = Plow.COLOR_RED;
break;
default:
color = Plow.COLOR_BLACK;
}
if ( highlight)
color = Plow.COLOR_RED;
cmn.gdraw.line(true, color, (float)((p1.x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((p1.y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)((p2.x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((p2.y + p.y) * cmn.zoom_factor - cmn.offset_y));
/*
Line2D.Double line = new Line2D.Double( (p1.x + p.x) * cmn.zoom_factor,
(p1.y + p.y) * cmn.zoom_factor,
(p2.x + p.x) * cmn.zoom_factor,
(p2.y + p.y) * cmn.zoom_factor);
switch ( draw_type) {
case Flow.eDrawType_LineDashed:
case Flow.eDrawType_LineDashedRed:
g.setStroke( new BasicStroke( (float)(cmn.zoom_factor / cmn.base_zoom_factor * line_width),
BasicStroke.CAP_BUTT,
BasicStroke.JOIN_BEVEL, 0,
new float[] { 4F * line_width, 2F * line_width},
0));
break;
default:
g.setStroke( new BasicStroke( (float)(cmn.zoom_factor / cmn.base_zoom_factor * line_width)));
}
switch ( draw_type) {
case Flow.eDrawType_LineGray:
g.setColor( Color.lightGray);
break;
case Flow.eDrawType_LineRed:
case Flow.eDrawType_LineDashedRed:
g.setColor( Color.red);
break;
default:
g.setColor( Color.black);
}
if ( highlight)
g.setColor( Color.red);
g.draw( line);
*/
}
@Override
public boolean getSelect() {
return false;
}
@Override
public void setSelect(boolean select) {
}
public boolean eventHandler(PlowEvent e) {
return false;
}
}
/*
* 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.app;
import jpwr.rt.*;
import java.io.*;
import java.util.*;
public class FlowNode implements FlowArrayElem {
static final int OFFSET = 2;
double x_right;
double x_left;
double y_high;
double y_low;
FlowCmn cmn;
FlowNodeClass nc;
FlowPoint pos;
String n_name;
String annotv[] = new String[10];
int annotsize[] = new int[10];
String trace_object;
String trace_attribute;
int trace_attr_type;
boolean highlight;
boolean select;
public FlowNode( FlowCmn cmn) {
this.cmn = cmn;
pos = new FlowPoint( cmn);
}
@Override
public int type() {
return Flow.eObjectType_Node;
}
public boolean getSelect() {
return select;
}
public void setSelect( boolean select) {
boolean redraw = (this.select != select);
this.select = select;
if ( redraw)
draw();
}
public String getName() {
return n_name;
}
public FlowCmn getCmn() {
return cmn;
}
public String getTraceObject() {
return trace_object;
}
public FlowDimension measureNode() {
return new FlowDimension(x_left, y_low, x_right, y_high);
}
public void setHighlight( boolean highlight) {
boolean redraw = (this.highlight != highlight);
this.highlight = highlight;
if ( redraw)
draw();
}
public void draw() {
// TODO
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
boolean found = false;
int i;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + line);
switch ( key) {
case Flow.eSave_Node_nc:
String nc_name = token.nextToken();
found = false;
for ( i = 0; i < cmn.a_nc.size(); i++) {
if ( ((FlowNodeClass)cmn.a_nc.get(i)).nc_name.equals( nc_name)) {
nc = (FlowNodeClass) cmn.a_nc.get(i);
found = true;
break;
}
}
if ( !found)
System.out.println( "FlowNode: NodeClass not found: " + nc_name);
break;
case Flow.eSave_Node_n_name:
if ( token.hasMoreTokens())
n_name = token.nextToken();
else
n_name = new String();
break;
case Flow.eSave_Node_refcon_cnt:
for ( i = 0; i < 32; i++)
reader.readLine();
break;
case Flow.eSave_Node_x_right:
x_right = new Double( token.nextToken()).doubleValue();
break;
case Flow.eSave_Node_x_left:
x_left = new Double( token.nextToken()).doubleValue();
break;
case Flow.eSave_Node_y_high:
y_high = new Double( token.nextToken()).doubleValue();
break;
case Flow.eSave_Node_y_low:
y_low = new Double( token.nextToken()).doubleValue();
break;
case Flow.eSave_Node_annotsize:
for ( i = 0; i < 10; i++) {
line = reader.readLine();
token = new StringTokenizer(line);
annotsize[i] = new Integer( token.nextToken()).intValue();
}
break;
case Flow.eSave_Node_annotv:
// Annotation are surrouded by quotes. A quote inside a
// annotation is preceded by a backslash. The size is calculated
// without backslashes
for ( i = 0; i < 10; i++) {
if ( annotsize[i] > 0) {
StringBuffer buf = new StringBuffer();
char c_old = 0;
char c;
reader.read();
for ( int j = 0; j < annotsize[i]; j++) {
c = (char) reader.read();
if ( c == '"') {
if ( c_old == '\\') {
buf.setLength( buf.length() - 1);
j--;
}
else
break;
}
buf.append(c); // TODO convert to UTF-8
c_old = c;
}
annotv[i] = new String( buf);
reader.readLine(); // Read linefeed
}
}
break;
case Flow.eSave_Node_pos:
pos.open( reader);
break;
case Flow.eSave_Node_trace_object:
if ( token.hasMoreTokens())
trace_object = token.nextToken();
break;
case Flow.eSave_Node_trace_attribute:
if ( token.hasMoreTokens())
trace_attribute = token.nextToken();
break;
case Flow.eSave_Node_trace_attr_type:
trace_attr_type = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Node_obst_x_right:
case Flow.eSave_Node_obst_x_left:
case Flow.eSave_Node_obst_y_high:
case Flow.eSave_Node_obst_y_low:
case Flow.eSave_Node_trace_inverted:
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowNode");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOException FlowNode");
}
/*
if ( nc.group == Flow.eNodeGroup_Common) {
this.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
if ( e.isPopupTrigger()) {
new JopMethodsMenu( cmn.session, trace_object, JopUtility.TRACE,
component, e.getX(), e.getY());
return;
}
}
public void mousePressed(MouseEvent e) {
System.out.println( "Mouse event" + n_name);
if ( e.isPopupTrigger()) {
new JopMethodsMenu( cmn.session, trace_object, JopUtility.TRACE,
component, e.getX(), e.getY());
return;
}
if ( select) {
setSelect( false);
}
else {
cmn.unselect();
setSelect( true);
}
}
public void mouseClicked(MouseEvent e) {
// Detect double click
if ( e.getClickCount() == 2) {
if ( trace_object == null || trace_object.equals(""))
return;
cmn.session.openCrrFrame( trace_object);
}
}
});
}
*/
}
public void draw( FlowPoint p0, String[] annotv0, boolean hl) {
if ( select) {
// Draw blue background
cmn.gdraw.rect(false, Plow.COLOR_LIGHTBLUE, (float)(x_left * cmn.zoom_factor - cmn.offset_x),
(float)(y_low * cmn.zoom_factor - cmn.offset_y),
(float)(x_right * cmn.zoom_factor - cmn.offset_x),
(float)(y_high * cmn.zoom_factor - cmn.offset_y));
}
nc.draw( pos, annotv, highlight);
}
public boolean eventHandler(PlowEvent e) {
System.out.println( "x(" + x_left + "," + x_right + ") (" + y_low + "," + y_high + ")");
switch ( e.type) {
case PlowEvent.TYPE_CLICK:
if (nc.group == Flow.eNodeGroup_Document)
return false;
if ( x_left <= e.x && e.x <= x_right &&
y_low <= e.y && e.y <= y_high) {
cmn.currentNode = this;
e.object = this;
System.out.println("Hit !!");
return true;
}
break;
}
return false;
}
boolean attrFound;
PwrtRefId subid;
int refid;
boolean oldValue;
boolean firstScan;
public Object dynamicGetRoot() {
return null;
}
public void dynamicOpen() {
if ( trace_object == null || trace_attribute == null ||
trace_object.equals(""))
return;
if ( trace_attr_type != Flow.eTraceType_Boolean)
return;
String attrName = trace_object + "." + trace_attribute;
GdhrRefObjectInfo ret = cmn.gdh.refObjectInfo( attrName);
if ( ret.evenSts())
System.out.println( "ObjectInfoError " + attrName);
else {
attrFound = true;
refid = ret.id;
subid = ret.refid;
if (trace_object.equals("H1-Dv1"))
System.out.println("FlowNode sts: " + ret.sts + " refid:" + refid + " " + trace_object + "." + trace_attribute);
}
}
public void dynamicClose() {
if ( attrFound)
cmn.gdh.unrefObjectInfo( subid);
}
public void dynamicUpdate( boolean animationOnly) {
if ( attrFound) {
boolean value = cmn.gdh.getObjectRefInfoBoolean( refid);
if (trace_object.equals("H1-Dv1"))
System.out.println("FlowNode value: " + value + " refid:" + refid + " " + trace_object + "." + trace_attribute);
if ( value != oldValue || firstScan) {
highlight = value;
oldValue = value;
}
}
}
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowNodeClass implements FlowArrayElem {
FlowArray a;
String nc_name;
public int group;
FlowCmn cmn;
public FlowNodeClass( FlowCmn cmn) {
this.cmn = cmn;
a = new FlowArray( cmn);
}
@Override
public int type() {
return Flow.eObjectType_NodeClass;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_NodeClass_nc_name:
nc_name = token.nextToken();
break;
case Flow.eSave_NodeClass_a:
a.open( reader);
break;
case Flow.eSave_NodeClass_group:
group = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_NodeClass_no_con_obstacle:
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowNodeClass");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowNodeClass");
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
a.draw( p, annotv, highlight);
}
@Override
public boolean getSelect() {
return false;
}
@Override
public void setSelect(boolean select) {
}
public boolean eventHandler(PlowEvent e) {
return false;
}
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowPoint {
double x;
double y;
FlowCmn cmn;
public FlowPoint( FlowCmn cmn) {
this.cmn = cmn;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_Point:
break;
case Flow.eSave_Point_x:
x = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_Point_y:
y = new Double(token.nextToken()).doubleValue();
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println("Syntax error in FlowPoint");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowRect");
}
}
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowRect implements FlowArrayElem {
FlowPoint ll;
FlowPoint ur;
int draw_type;
int line_width;
int display_level;
FlowCmn cmn;
public FlowRect( FlowCmn cmn) {
this.cmn = cmn;
ll = new FlowPoint(cmn);
ur = new FlowPoint(cmn);
}
@Override
public int type() {
return Flow.eObjectType_Rect;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_Rect_draw_type:
draw_type = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Rect_line_width:
line_width = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Rect_display_level:
display_level = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Rect_ll:
ll.open( reader);
break;
case Flow.eSave_Rect_ur:
ur.open( reader);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowRect");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowRect");
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
if ( (display_level & FlowCmn.display_level) == 0)
return;
int color;
if ( highlight)
color = Plow.COLOR_RED;
else
color = Plow.COLOR_BLACK;
cmn.gdraw.rect(true, color, (float)((ll.x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((ll.y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)((ur.x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((ur.y + p.y) * cmn.zoom_factor - cmn.offset_y));
}
@Override
public boolean getSelect() {
return false;
}
@Override
public void setSelect(boolean select) {
}
public boolean eventHandler(PlowEvent e) {
return false;
}
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowText implements FlowArrayElem {
FlowPoint p;
int draw_type;
int text_size;
String text;
FlowCmn cmn;
public FlowText( FlowCmn cmn) {
this.cmn = cmn;
p = new FlowPoint(cmn);
}
@Override
public int type() {
return Flow.eObjectType_Text;
}
public void open( BufferedReader reader) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_Text:
break;
case Flow.eSave_Text_text_size:
text_size = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Text_draw_type:
draw_type = new Integer(token.nextToken()).intValue();
break;
case Flow.eSave_Text_text:
text = token.nextToken();
break;
case Flow.eSave_Text_p:
p.open( reader);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowText");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowText");
}
}
public void draw( FlowPoint p0, String[] annotv, boolean highlight) {
int tsize;
int idx = (int) (cmn.zoom_factor/cmn.base_zoom_factor * text_size * 5.8 + 1.0);
if ( cmn.zoom_factor/cmn.base_zoom_factor * text_size * 6.5 < 2) return;
int color = Flow.eDrawType_Line;
if ( highlight)
color = Flow.eDrawType_LineRed;
cmn.gdraw.drawText( text, color, idx, 0, (float)((p.x + p0.x) * cmn.zoom_factor - cmn.offset_x),
(float)((p.y + p0.y) * cmn.zoom_factor - cmn.offset_y));
}
@Override
public boolean getSelect() {
return false;
}
@Override
public void setSelect(boolean select) {
}
public boolean eventHandler(PlowEvent e) {
return false;
}
}
/*
* 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.app;
import java.io.*;
import java.util.*;
public class FlowVector {
public FlowVector() {
}
//public static void open( BufferedReader reader, FlowCmn cmn, Vector<Object> a) {
public static void open( BufferedReader reader, FlowCmn cmn, Vector a) {
String line;
StringTokenizer token;
boolean end = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = new Integer(token.nextToken()).intValue();
if ( cmn.debug) System.out.println( "line : " + key);
switch ( key) {
case Flow.eSave_Array:
break;
case Flow.eSave_NodeClass:
FlowNodeClass nc = new FlowNodeClass( cmn);
nc.open( reader);
a.add( (Object) nc);
break;
case Flow.eSave_ConClass:
FlowConClass cc = new FlowConClass( cmn);
cc.open( reader);
a.add( (Object) cc);
break;
case Flow.eSave_Node:
FlowNode n = new FlowNode( cmn);
n.open( reader);
a.add( n);
break;
case Flow.eSave_Con:
FlowCon c = new FlowCon( cmn);
c.open( reader);
a.add( c);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowVector");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowVector");
}
}
}
package jpwr.app;
import android.graphics.Canvas;
import android.view.MotionEvent;
import jpwr.jopg.*;
public class GraphCmn implements PlowCmnIfc {
public static final int ACTION_CLICK = 1;
public static final int ACTION_UP = 2;
public static final int ACTION_DOWN = 3;
public static final int ACTION_MOVE = 4;
public Graph graph;
int scanCount = 0;
double buttonDownX;
double buttonDownY;
public GraphCmn(Graph graph) {
this.graph = graph;
}
public int type() {
return PlowCmnIfc.TYPE_GRAPH;
}
public Object getUserData() {
return null;
}
public void setUserData(Object userData) {
}
public void draw() {
graph.ctx.draw();
}
public void zoom(double factor) {
graph.ctx.zoom(factor);
}
public void scroll( int x, int y) {}
public void pageUp() {}
public void pageDown() {}
public synchronized void eventHandler(int action, double fx, double fy) {
switch ( action) {
case ACTION_UP: {
GlowEvent event = new GlowEvent();
event.x = (fx + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (fy + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_MB1Up;
graph.cmn.setNodraw();
graph.ctx.eventHandler( event);
graph.cmn.resetNodraw();
break;
}
case ACTION_CLICK: {
GlowEvent event = new GlowEvent();
event.x = (fx + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (fy + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_MB1Up;
graph.cmn.setNodraw();
graph.ctx.eventHandler( event);
graph.cmn.resetNodraw();
System.out.println("GraphCmn event click");
GlowEvent event2 = new GlowEvent();
event2.x = (fx + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event2.y = (fy + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event2.event = Glow.eEvent_MB1Click;
graph.cmn.setNodraw();
graph.ctx.eventHandler( event2);
graph.cmn.resetNodraw();
break;
}
case ACTION_DOWN: {
GlowEvent event = new GlowEvent();
event.x = (fx + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (fy + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_MB1Down;
graph.cmn.setNodraw();
graph.ctx.eventHandler( event);
graph.cmn.resetNodraw();
buttonDownX = event.x;
buttonDownY = event.y;
break;
}
case ACTION_MOVE: {
GlowEvent event = new GlowEvent();
event.x = (fx + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (fy + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_ButtonMotion;
graph.cmn.setNodraw();
graph.ctx.eventHandler( event);
graph.cmn.resetNodraw();
break;
}
}
}
public void select(Object node) {}
public void selectClear() {}
public Object getSelect() {return null;}
public void configure() {}
public void dynamicOpen() {}
public void dynamicClose() {
graph.ctx.traceDisconnect();
}
public synchronized void dynamicUpdate() {
/*
scanCount++;
if ( scanCount == 1)
graph.gdh.getObjectRefInfoAll();
*/
graph.cmn.setNodraw();
graph.ctx.traceScan();
graph.cmn.resetNodraw();
}
public void setCanvas(Canvas canvas) {
graph.cmn.gdraw.setCanvas(canvas);
}
public Object getFirst() {
return null;
}
public Object getLast() {
return null;
}
public Object getNext(Object elem) {
return null;
}
public Object getPrevious(Object elem) {
return null;
}
public int remove(Object e) {
return 0;
}
}
package jpwr.app;
public class Plow {
public static final int DRAWOFFSET = 2;
public static final int DEST_INTOLAST = 0;
public static final int DEST_INTOFIRST = 1;
public static final int DEST_AFTER = 2;
public static final int DEST_BEFORE = 3;
public static final double TREE_INDENTATION = 1D;
public static final int OPEN_ATTRIBUTES = 1;
public static final int OPEN_CHILDREN = 2;
public static final int OPEN_CROSSREFERENCES = 4;
public static final int OPEN_ALL = OPEN_ATTRIBUTES | OPEN_CHILDREN | OPEN_CROSSREFERENCES;
public static final int COLOR_BLACK = 1;
public static final int COLOR_RED = 2;
public static final int COLOR_GRAY = 3;
public static final int COLOR_DARKGRAY = 4;
public static final int COLOR_LIGHTGRAY = 5;
public static final int COLOR_WHITE = 6;
public static final int COLOR_YELLOW = 7;
public static final int COLOR_GREEN = 8;
public static final int COLOR_LIGHTBLUE = 9;
public static final int COLOR_BLUE = 10;
public static final int COLOR_VIOLET = 11;
}
package jpwr.app;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
public class PlowAnnot implements PlowArrayElem {
public static final int RELATIVE_POSITION = 1;
public static final int NEXT_RELATIVE_POSITION = 2;
public static final double RELATIVE_OFFSET = 1D;
double x;
double y;
int textSize;
int textColor;
int annotType;
int font;
int number;
PlowCmn cmn;
public PlowAnnot(PlowCmn cmn, double x, double y, int textSize, int textColor, int font,
int annotType, int number) {
this.cmn = cmn;
this.x = x;
this.y = y;
this.textSize = textSize;
this.textColor = textColor;
this.font = font;
this.annotType = annotType;
this.number = number;
}
public void draw(PlowPoint p, PlowNodeIfc node) {
if ( node == null || node.getAnnot(number) == null)
return;
int size = (int) (cmn.zoom_factor/cmn.base_zoom_factor * textSize);
double xPos;
int color;
if ( node.getInvert())
color = Plow.COLOR_WHITE;
else
color = textColor;
if ( (annotType & RELATIVE_POSITION) != 0) {
xPos = p.x + node.getAnnotPosition() + RELATIVE_OFFSET;
if ( xPos < p.x + x)
xPos = p.x + x;
}
else
xPos = p.x + x;
cmn.gdraw.drawText(node.getAnnot(number), color, size, font, (float)((xPos) * cmn.zoom_factor - cmn.offset_x),
(float)((y + p.y) * cmn.zoom_factor - cmn.offset_y));
if ( (annotType & NEXT_RELATIVE_POSITION) != 0)
node.setAnnotPosition(xPos - p.x + cmn.gdraw.measureText(node.getAnnot(number), size, font)/cmn.zoom_factor);
}
public void setBorders(PlowBorders borders) {
double width = 0;
double height = 0;
if ( x < borders.x_left)
borders.x_left = x;
if ( x + width > borders.x_right)
borders.x_right = x + width;
if ( y < borders.y_low)
borders.y_low = y;
if ( y + height > borders.y_high)
borders.y_high = y + height;
}
public boolean eventHandler(PlowEvent e) {
return false;
}
public void setInvert(boolean invert) {
}
public void draw(double x_left, double y_low, double x_right, double y_high) {
}
}
package jpwr.app;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
public class PlowAnnotPixmap implements PlowArrayElem {
double x;
double y;
int number;
PlowCmn cmn;
static float[] inv = { -1f, 0f, 0f, 1f, 1f,
0f,-1f, 0f, 1f, 1f,
0f, 0f,-1f, 1f, 1f,
0f, 0f, 0f, 1f, 0f};
public PlowAnnotPixmap(PlowCmn cmn, double x, double y, int number) {
this.cmn = cmn;
this.x = x;
this.y = y;
this.number = number;
}
public void draw(PlowPoint p, PlowNodeIfc node) {
if ( node == null || node.getPixmap(number) == null)
return;
boolean invert = ( node != null && node.getInvert());
int idx = (int)(cmn.zoom_factor/cmn.base_zoom_factor * 6 - 3);
if ( idx < 0)
idx = 0;
if ( idx > 7)
idx = 7;
cmn.gdraw.pixmap(node.getPixmap(number), idx, invert, (float)((x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((y + p.y) * cmn.zoom_factor - cmn.offset_y));
}
public void setBorders(PlowBorders borders) {
double width = 0;
double height = 0;
if ( x < borders.x_left)
borders.x_left = x;
if ( x + width > borders.x_right)
borders.x_right = x + width;
if ( y < borders.y_low)
borders.y_low = y;
if ( y + height > borders.y_high)
borders.y_high = y + height;
}
public boolean eventHandler(PlowEvent e) {
return false;
}
public void setInvert(boolean invert) {
}
public void draw(double x_left, double y_low, double x_right, double y_high) {
}
}
package jpwr.app;
import android.content.res.Resources;
public interface PlowAppl {
public void eventHandler(PlowEvent e);
public Resources getApplResources();
}
package jpwr.app;
import java.util.Vector;
public class PlowArray {
//Vector<Object> a = new Vector<Object>();
Vector<PlowArrayElem> a = new Vector<PlowArrayElem>();
PlowCmn cmn;
public PlowArray( PlowCmn cmn) {
this.cmn = cmn;
}
public void draw( PlowPoint p, PlowNodeIfc node) {
for ( int i = 0; i < a.size(); i++) {
((PlowArrayElem)a.get(i)).draw(p, node);
}
}
public void draw() {
PlowPoint p = new PlowPoint();
for ( int i = 0; i < a.size(); i++) {
((PlowArrayElem)a.get(i)).draw( p, null);
}
}
public void draw(double x_left, double y_low, double x_right, double y_high) {
for ( int i = 0; i < a.size(); i++) {
((PlowArrayElem)a.get(i)).draw(x_left, y_low, x_right, y_high);
}
}
public void setBorders(PlowBorders borders) {
for ( int i = 0; i < a.size(); i++) {
((PlowArrayElem)a.get(i)).setBorders(borders);
}
}
public void insert( PlowArrayElem e) {
a.add(e);
}
public boolean insertNode(PlowArrayElem e, PlowArrayElem destination, int code) {
if ( find(e))
return false;
int idx;
int destination_level = 0;
if ( destination == null) {
switch ( code) {
case Plow.DEST_INTOLAST:
idx = a.size();
break;
default:
idx = 0;
}
destination_level = 0;
}
else {
boolean found = false;
for ( idx = 0; idx < a.size(); idx++) {
if ( a.get(idx) == destination) {
found = true;
destination_level = ((PlowNode)a.get(idx)).getLevel();
idx++;
break;
}
}
if ( !found)
return false;
}
switch ( code) {
case Plow.DEST_INTOFIRST:
a.insertElementAt(e, idx);
if ( destination != null)
((PlowNode)e).setLevel(destination_level + 1);
else
((PlowNode)e).setLevel(destination_level);
break;
case Plow.DEST_INTOLAST: {
int i;
for ( i = idx; i < a.size(); i++) {
if ( ((PlowNode)a.get(i)).getLevel() <= destination_level)
break;
}
idx = i;
a.insertElementAt(e, idx);
if ( destination != null)
((PlowNode)e).setLevel(destination_level + 1);
else
((PlowNode)e).setLevel(destination_level);
break;
}
case Plow.DEST_AFTER: {
int i;
for ( i = idx; i < a.size(); i++) {
if ( ((PlowNode)a.get(i)).getLevel() < destination_level)
break;
}
idx = i;
a.insertElementAt(e, idx);
((PlowNode)e).setLevel(destination_level);
break;
}
case Plow.DEST_BEFORE:
if ( idx > 0)
idx--;
a.insertElementAt(e, idx);
((PlowNode)e).setLevel(destination_level);
break;
}
return true;
}
public void closeNode(PlowArrayElem element) {
boolean found = false;
int idx = 0;
int next_idx;
int i;
for ( i = 0; i < a.size(); i++) {
if ( a.get(i) == element) {
idx = i;
found = true;
break;
}
}
if ( !found)
return;
int level = ((PlowNode)a.get(idx)).getLevel();
for ( i = idx + 1; i < a.size(); i++) {
if ( ((PlowNode)a.get(i)).getLevel() <= level)
break;
}
next_idx = i;
if ( next_idx == idx + 1)
return;
for ( i = idx + 1; i < next_idx; i++) {
PlowEvent e = new PlowEvent(PlowEvent.TYPE_OBJECT_DELETED, 0D, 0D, (PlowNode)a.get(i));
cmn.appl.eventHandler(e);
if ( cmn.getSelect() == a.get(i))
cmn.selectClear();
a.remove(i);
i--;
next_idx--;
}
}
public boolean eventHandler(PlowEvent e) {
for ( int i = 0; i < a.size(); i++) {
if ( ((PlowArrayElem)a.get(i)).eventHandler(e))
return true;
}
return false;
}
public void setInvert(boolean invert) {
for ( int i = 0; i < a.size(); i++) {
((PlowArrayElem)a.get(i)).setInvert(invert);
}
}
public void configure() {
for ( int i = 0; i < a.size(); i++) {
if ( i == 0)
((PlowNode)a.get(i)).configure(null);
else
((PlowNode)a.get(i)).configure((PlowNode)a.get(i-1));
}
}
public boolean find(PlowArrayElem e) {
for ( int i = 0; i < a.size(); i++) {
if ( a.get(i) == e)
return true;
}
return false;
}
public PlowArrayElem get_next( PlowArrayElem element) {
int i;
for ( i = 0; i < a.size(); i++) {
if ( a.get(i) == element) {
if ( i == a.size() - 1)
return null;
return a.get(i+1);
}
}
return null;
}
public PlowArrayElem get_previous( PlowArrayElem element) {
int i;
for ( i = 0; i < a.size(); i++) {
if ( a.get(i) == element) {
if ( i == 0)
return null;
return a.get(i-1);
}
}
return null;
}
public PlowArrayElem get_first() {
if ( a.size() == 0)
return null;
return a.get(0);
}
public PlowArrayElem get_last() {
if ( a.size() == 0)
return null;
return a.get(a.size() - 1);
}
public int remove(PlowArrayElem e) {
if ( a.remove(e))
return 1;
return 0;
}
}
package jpwr.app;
public interface PlowArrayElem {
public void draw(PlowPoint p, PlowNodeIfc node);
public void draw(double x_left, double y_low, double x_right, double y_high);
public void setBorders(PlowBorders borders);
public boolean eventHandler(PlowEvent e);
public void setInvert(boolean invert);
}
package jpwr.app;
public class PlowBorders {
public double x_right;
public double x_left;
public double y_high;
public double y_low;
PlowBorders() {
x_right = 0;
x_left = 0;
y_high = 0;
y_low = 0;
}
}
package jpwr.app;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.view.MotionEvent;
public class PlowCmn implements PlowCmnIfc {
// public Canvas canvas;
public PlowDraw gdraw;
PlowAppl appl;
double zoom_factor;
double base_zoom_factor;
int offset_x;
int offset_y;
double x_right;
double x_left;
double y_high;
double y_low;
int canvasWidth;
int canvasHeight;
PlowArray a;
PlowArray a_nc;
PlowNode currentNode;
PlowNode selectedNode;
PlowBorders borders;
Object userData;
public PlowCmn(PlowAppl appl, double zoom_factor) {
this.appl = appl;
this.zoom_factor = zoom_factor;
base_zoom_factor = zoom_factor;
offset_x = 0;
offset_y = 0;
currentNode = null;
borders = new PlowBorders();
a = new PlowArray(this);
a_nc = new PlowArray(this);
}
@Override
public int type() {
return PlowCmnIfc.TYPE_PLOW;
}
public void setGDraw(PlowDraw gdraw) {
this.gdraw = gdraw;
canvasWidth = gdraw.getCanvasWidth();
canvasHeight = gdraw.getCanvasHeight();
}
public Resources getResources() {
return appl.getApplResources();
}
public void insert(PlowArrayElem e) {
a.insert(e);
}
public void insertNode(PlowArrayElem e, PlowArrayElem destination, int destCode) {
a.insertNode(e, destination, destCode);
}
public void closeNode(PlowArrayElem e) {
a.closeNode(e);
}
public void insert_nc(PlowArrayElem e) {
a_nc.insert(e);
}
public void draw(double x_left, double y_low, double x_right, double y_high) {
gdraw.canvas.save(Canvas.CLIP_SAVE_FLAG);
gdraw.canvas.clipRect((float)x_left, (float)y_high, (float)x_right, (float)y_low);
a.draw(x_left, y_low, x_right, y_high);
gdraw.canvas.restore();
}
@Override
public void eventHandler(int action, double fx, double fy) {
double x = (fx + offset_x) / zoom_factor;
double y = (fy + offset_y) / zoom_factor;
int type;
switch( action) {
case MotionEvent.ACTION_UP:
type = PlowEvent.TYPE_CLICK;
break;
default:
return;
}
System.out.println("Event: " + type + "(" + x + "," + y + ")");
PlowEvent e = new PlowEvent(type, x, y, null);
currentNode = null;
a.eventHandler(e);
appl.eventHandler(e);
switch (e.type) {
case PlowEvent.TYPE_OBJECT_DELETED:
if ( currentNode == selectedNode)
selectedNode = null;
break;
}
}
public void draw() {
a.draw();
}
public void zoom(double factor) {
zoom_factor *= factor;
draw();
}
public void scroll( int x, int y) {
offset_y += y;
// offset_x += x;
if ( offset_y < borders.y_low * zoom_factor)
offset_y = (int)(borders.y_low * zoom_factor);
if ( offset_y > borders.y_high * zoom_factor - canvasHeight + 80)
offset_y = (int)(borders.y_high * zoom_factor - canvasHeight + 80);
}
public void pageUp() {
offset_y -= canvasHeight * 0.8;
if ( offset_y < borders.y_low * zoom_factor)
offset_y = (int)(borders.y_low * zoom_factor);
}
public void pageDown() {
offset_y += canvasHeight * 0.8;
if ( offset_y > borders.y_high * zoom_factor - canvasHeight + 80)
offset_y = (int)(borders.y_high * zoom_factor - canvasHeight + 80);
}
public void configure() {
a.configure();
a.setBorders(borders);
}
public int size() {
return a.a.size();
}
public PlowArrayElem get(int i) {
return a.a.get(i);
}
@Override
public void select(Object node) {
selectedNode = (PlowNode)node;
}
@Override
public void selectClear() {
selectedNode = null;
}
@Override
public PlowNode getSelect() {
return selectedNode;
}
public void resetInvert() {
a.setInvert(false);
}
public void dynamicOpen() {}
public void dynamicClose() {}
public void dynamicUpdate() {}
public Object getUserData() {
return userData;
}
public void setUserData(Object userData) {
this.userData = userData;
}
public void setCanvas(Canvas canvas) {
gdraw.setCanvas(canvas);
}
public Object getFirst() {
return a.get_first();
}
public Object getLast() {
return a.get_last();
}
public Object getNext(Object elem) {
return a.get_next((PlowArrayElem)elem);
}
public Object getPrevious(Object elem) {
return a.get_previous((PlowArrayElem)elem);
}
public int remove(Object e) {
return a.remove((PlowArrayElem)e);
}
public void clear() {
a.a.clear();
selectClear();
}
}
package jpwr.app;
public class PlowCmnEv extends PlowCmn {
public PlowCmnEv(PlowAppl appl, double zoom_factor) {
super(appl, zoom_factor);
}
public int type() {
return PlowCmnIfc.TYPE_EV;
}
}
package jpwr.app;
import android.graphics.Canvas;
public interface PlowCmnIfc {
public static final int TYPE_PLOW = 1;
public static final int TYPE_FLOW = 2;
public static final int TYPE_GRAPH = 3;
public static final int TYPE_EV = 4;
public int type();
public Object getUserData();
public void setUserData(Object userData);
public void draw();
public void zoom(double factor);
public void scroll( int x, int y);
public void pageUp();
public void pageDown();
public void eventHandler(int action, double fx, double fy);
public void select(Object node);
public void selectClear();
public Object getSelect();
public void configure();
public void dynamicOpen();
public void dynamicClose();
public void dynamicUpdate();
public void setCanvas(Canvas canvas);
public Object getFirst();
public Object getLast();
public Object getNext(Object elem);
public Object getPrevious(Object elem);
public int remove(Object e);
}
package jpwr.app;
public interface PlowComponent {
public void setBounds();
public void setSelect( boolean select);
public boolean getSelect();
public String getTraceObject();
public String getName();
}
package jpwr.app;
public class PlowDimension {
public int x;
public int y;
public int width;
public int height;
}
package jpwr.app;
import java.io.UnsupportedEncodingException;
import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Typeface;
public class PlowDraw implements PlowDrawIfc {
public static final int FONT_NOMAL = 0;
public static final int FONT_NORMAL_BOLD = 1;
public static final int FONT_SANSSERIF = 2;
public static final int FONT_SANSSERIF_BOLD = 3;
public static final int FONT_DROIDSANS = 4;
public static final int FONT_DROIDSANS_BOLD = 5;
Activity activity;
Canvas canvas;
Paint paint;
Typeface[] fonts = new Typeface[6];
int canvasWidth;
int canvasHeight;
static float[] inv = { -1f, 0f, 0f, 1f, 1f,
0f,-1f, 0f, 1f, 1f,
0f, 0f,-1f, 1f, 1f,
0f, 0f, 0f, 1f, 0f};
public PlowDraw(Activity activity) {
this.activity = activity;
paint = new Paint();
fonts[0] = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL);
fonts[1] = Typeface.create(Typeface.DEFAULT, Typeface.BOLD);
fonts[2] = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL);
fonts[3] = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD);
fonts[4] = Typeface.createFromAsset(activity.getAssets(), "fonts/DroidSans.ttf");
fonts[5] = Typeface.createFromAsset(activity.getAssets(), "fonts/DroidSans-Bold.ttf");
}
public void setCanvas(Canvas canvas) {
this.canvas = canvas;
canvasWidth = canvas.getWidth();
canvasHeight = canvas.getHeight();
}
public int getCanvasWidth() {
return canvasWidth;
}
public int getCanvasHeight() {
return canvasHeight;
}
@Override
public void rect(boolean border, int color, float x1, float y1, float x2, float y2) {
if ( border) {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
canvas.drawRect(x1, y1, x2, y2, paint);
}
else {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.FILL);
canvas.drawRect(x1, y1, x2, y2, paint);
}
}
@Override
public void arc(boolean border, int color, float x1, float y1, float x2, float y2, float angel1, float angel2) {
if ( border) {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
canvas.drawArc(new RectF(x1, y1, x2, y2), 360-angel1, -angel2, false, paint);
}
else {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.FILL);
canvas.drawArc(new RectF(x1, y1, x2, y2), 360-angel1, -angel2, true, paint);
}
}
@Override
public void line(boolean border, int color, float x1, float y1, float x2, float y2) {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
canvas.drawLine(x1, y1, x2, y2, paint);
}
@Override
public void pixmap(PlowPixmapData pixmapData, int idx, boolean invert, float x, float y) {
if ( invert) {
ColorMatrix cm = new ColorMatrix(inv);
paint.setColorFilter(new ColorMatrixColorFilter(cm));
}
else
paint.setColor(Color.BLACK);
canvas.drawBitmap(pixmapData.bitmap[idx], x, y, paint);
if ( invert)
paint.setColorFilter(null);
}
@Override
public void drawText( String text, int textColor, int textSize, int font, float x, float y) {
paint.setTextSize(textSize);
paint.setTypeface(fonts[font]);
paint.setColor(getColor(textColor));
paint.setStyle(Paint.Style.FILL);
canvas.drawText( text, x, y, paint);
}
@Override
public float measureText( String text, int textSize, int font) {
paint.setTextSize(textSize);
paint.setTypeface(null);
return paint.measureText(text);
}
public void arrow(int color, float x1, float y1, float x2, float y2, float x3, float y3) {
Path path = new Path();
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.FILL);
path.moveTo(x1, y1);
path.lineTo(x2, y2);
path.lineTo(x3, y3);
path.lineTo(x1, y1);
canvas.drawPath(path, paint);
}
public int getColor(int color) {
switch ( color) {
case Plow.COLOR_BLACK:
return Color.BLACK;
case Plow.COLOR_RED:
return Color.RED;
case Plow.COLOR_WHITE:
return Color.WHITE;
case Plow.COLOR_GRAY:
return Color.GRAY;
case Plow.COLOR_DARKGRAY:
return Color.DKGRAY;
case Plow.COLOR_LIGHTGRAY:
return Color.LTGRAY;
case Plow.COLOR_YELLOW:
return Color.YELLOW;
case Plow.COLOR_GREEN:
return Color.GREEN;
case Plow.COLOR_LIGHTBLUE:
return Color.rgb(196, 200, 240);
case Plow.COLOR_BLUE:
return Color.rgb(195,226,255);
case Plow.COLOR_VIOLET:
return Color.rgb(218,198,255);
default:
return Color.BLACK;
}
}
}
package jpwr.app;
import android.graphics.Canvas;
public interface PlowDrawIfc {
public void rect(boolean border, int color, float x1, float y1, float x2, float y2);
public void arc(boolean border, int color, float x1, float y1, float x2, float y2, float angel1, float angel2);
public void line(boolean border, int color, float x1, float y1, float x2, float y2);
public void pixmap(PlowPixmapData pixmapData, int idx, boolean invert, float x, float y);
public void drawText( String text, int textColor, int textSize, int font, float x, float y);
public float measureText( String text, int textSize, int font);
public void arrow(int color, float x1, float y1, float x2, float y2, float x3, float y3);
public int getCanvasWidth();
public int getCanvasHeight();
public void setCanvas(Canvas canvas);
}
package jpwr.app;
public class PlowEvent {
public static final int TYPE_CLICK = 1;
public static final int TYPE_OBJECT_DELETED = 2;
public int type;
public double x;
public double y;
public Object object;
public boolean inIcon;
PlowEvent(int type, double x, double y, Object object) {
this.type = type;
this.x = x;
this.y = y;
this.object = object;
this.inIcon = false;
}
}
package jpwr.app;
public class PlowNode implements PlowComponent, PlowArrayElem, PlowNodeIfc {
static final int OFFSET = 2;
static final double ICON_SIZE = 3D;
PlowBorders borders = new PlowBorders();
PlowCmn cmn;
PlowNodeClass nc;
PlowPoint pos;
String n_name;
String annotv[] = new String[10];
PlowPixmapData pixmapv[] = new PlowPixmapData[3];
int annotsize[] = new int[10];
String trace_object;
String trace_attribute;
int trace_attr_type;
boolean highlight;
boolean select;
boolean invert;
PlowDimension bounds = new PlowDimension();
double annotPosition;
Object userData;
int level;
int nodeOpen;
public PlowNode( PlowCmn cmn, double x, double y, PlowNodeClass nc) {
this.cmn = cmn;
this.nc = nc;
pos = new PlowPoint(x, y);
setBorders();
}
public boolean getSelect() {
return select;
}
public void setSelect( boolean select) {
boolean redraw = (this.select != select);
this.select = select;
if ( redraw)
draw();
}
public void setAnnotation(int number, String text, int size) {
if ( number >= 10)
return;
annotv[number] = text;
annotsize[number] = size;
}
public void setAnnotPixmap(int number, PlowPixmapData data) {
if ( number >= 3)
return;
pixmapv[number] = data;
}
public boolean eventHandler(PlowEvent e) {
System.out.println( "x(" + borders.x_left + "," + borders.x_right + ") (" + borders.y_low + "," + borders.y_high + ")");
switch ( e.type) {
case PlowEvent.TYPE_CLICK:
if ( borders.x_left <= e.x && e.x <= borders.x_right &&
borders.y_low <= e.y && e.y <= borders.y_high) {
cmn.currentNode = this;
e.object = this;
if ( e.x < borders.x_left + ICON_SIZE)
e.inIcon = true;
else
e.inIcon = false;
System.out.println("Hit !!");
return true;
}
break;
}
return false;
}
public String getName() {
return n_name;
}
public String getTraceObject() {
return trace_object;
}
public void setHighlight( boolean highlight) {
boolean redraw = (this.highlight != highlight);
this.highlight = highlight;
if ( redraw)
draw();
}
public void setBorders() {
borders.x_left = 1e37;
borders.x_right = -1e37;
borders.y_low = 1e37;
borders.y_high = -1e37;
nc.setBorders( borders);
borders.x_left += pos.x;
borders.x_right += pos.x;
borders.y_low += pos.y;
borders.y_high += pos.y;
}
public void setBorders(PlowBorders borders) {
if ( this.borders.x_left < borders.x_left)
borders.x_left = this.borders.x_left;
if ( this.borders.x_right > borders.x_right)
borders.x_right = this.borders.x_right;
if ( this.borders.y_low < borders.y_low)
borders.y_low = this.borders.y_low;
if ( this.borders.y_high > borders.y_high)
borders.y_high = this.borders.y_high;
}
public void setBounds() {
bounds.x = (int)((borders.x_left - cmn.x_left) * cmn.zoom_factor) - Plow.DRAWOFFSET;
bounds.y = (int)((borders.y_low - cmn.y_low) * cmn.zoom_factor) - Plow.DRAWOFFSET;
bounds.width = (int)((borders.x_right - borders.x_left) * cmn.zoom_factor) + 2 * Plow.DRAWOFFSET;
bounds.height = (int)((borders.y_high - borders.y_low) * cmn.zoom_factor) + 2 * Plow.DRAWOFFSET;
}
public void draw() {
cmn.draw(borders.x_left, borders.y_low, borders.x_right, borders.y_high);
}
public void draw(double x_left, double y_low, double x_right, double y_high) {
if ( borders.x_left < x_right && borders.x_right > x_left &&
borders.y_low < y_high && borders.y_high > y_low) {
draw( pos, this);
}
}
public void draw(PlowPoint pp, PlowNodeIfc node) {
nc.draw( pos, this);
}
public void setInvert(boolean invert) {
if ( invert == this.invert)
return;
this.invert = invert;
draw();
}
public void configure(PlowNode previous) {
if ( previous == null) {
pos.x = 0;
pos.y = 0;
}
else {
pos.x = Plow.TREE_INDENTATION * level;
pos.y = previous.borders.y_high;
}
setBorders();
}
public String getAnnot(int number) {
return annotv[number];
}
public PlowPixmapData getPixmap(int number) {
return pixmapv[number];
}
public boolean getHighlight() {
return highlight;
}
public boolean getInvert() {
return invert;
}
public void setAnnotPosition(double pos) {
annotPosition = pos;
}
public double getAnnotPosition() {
return annotPosition;
}
public void setUserData( Object userData) {
this.userData = userData;
}
public Object getUserData() {
return userData;
}
public void setLevel(int level) {
this.level = level;
}
public int getLevel() {
return level;
}
public int getNodeOpen() {
return nodeOpen;
}
public void setNodeOpen(int mask) {
this.nodeOpen |= mask;
}
public void resetNodeOpen(int mask) {
this.nodeOpen &= ~mask;
}
}
package jpwr.app;
public class PlowNodeClass implements PlowArrayElem {
PlowArray a;
String nc_name;
int group;
PlowCmn cmn;
public PlowNodeClass( PlowCmn cmn) {
this.cmn = cmn;
a = new PlowArray( cmn);
}
public void insert( PlowArrayElem e) {
a.insert(e);
}
public void draw( PlowPoint p, PlowNodeIfc node) {
a.draw( p, node);
}
public void setBorders(PlowBorders borders) {
a.setBorders(borders);
}
public void setInvert(boolean invert) {
}
public boolean eventHandler(PlowEvent e) {
return false;
}
public void draw(double x_left, double y_low, double x_right, double y_high) {
}
}
package jpwr.app;
public interface PlowNodeIfc {
public String getAnnot(int number);
public PlowPixmapData getPixmap(int number);
public boolean getHighlight();
public boolean getInvert();
public double getAnnotPosition();
public void setAnnotPosition(double pos);
}
package jpwr.app;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
public class PlowPixmap implements PlowArrayElem {
PlowCmn cmn;
int id;
double x;
double y;
PlowPixmapData data;
static float[] inv = { -1f, 0f, 0f, 1f, 1f,
0f,-1f, 0f, 1f, 1f,
0f, 0f,-1f, 1f, 1f,
0f, 0f, 0f, 1f, 0f};
public PlowPixmap(PlowCmn cmn, double x, double y, PlowPixmapData data) {
this.cmn = cmn;
this.data = data;
this.x = x;
this.y = y;
}
public void draw(PlowPoint p, PlowNodeIfc node) {
boolean invert = (node != null && node.getInvert());
int idx = (int)(cmn.zoom_factor/cmn.base_zoom_factor * 6 - 3);
if ( idx < 0)
idx = 0;
if ( idx > 7)
idx = 7;
cmn.gdraw.pixmap(data, idx, invert, (float)((x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((y + p.y) * cmn.zoom_factor - cmn.offset_y));
}
@Override
public void setBorders(PlowBorders borders) {
double width = 0;
double height = 0;
if ( x < borders.x_left)
borders.x_left = x;
if ( x + width > borders.x_right)
borders.x_right = x + width;
if ( y < borders.y_low)
borders.y_low = y;
if ( y + height > borders.y_high)
borders.y_high = y + height;
}
public boolean eventHandler(PlowEvent e) {
return false;
}
public void setInvert(boolean invert) {
}
public void draw(double x_left, double y_low, double x_right, double y_high) {
}
}
package jpwr.app;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
public class PlowPixmapData {
Bitmap[] bitmap = new Bitmap[8];
public PlowPixmapData(PlowCmn cmn, int id) {
Bitmap bm = BitmapFactory.decodeResource( cmn.getResources(), id);
int width = bm.getWidth();
int height = bm.getHeight();
for ( int i = 0; i < 8; i++) {
Matrix matrix = new Matrix();
matrix.postScale(0.25f + 0.5f * i, 0.25f + 0.5f * i);
bitmap[i] = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
}
}
public PlowPixmapData(PlowCmn cmn, int[] id) {
for ( int i = 0; i < 8; i++) {
Bitmap bm = BitmapFactory.decodeResource( cmn.getResources(), id[i]);
int width = bm.getWidth();
int height = bm.getHeight();
Matrix matrix = new Matrix();
bitmap[i] = Bitmap.createBitmap(bm, 0, 0, width, height, null, false);
}
}
}
package jpwr.app;
public class PlowPoint {
public double x;
public double y;
public PlowPoint( double x, double y) {
this.x = x;
this.y = y;
}
public PlowPoint() {
this.x = 0;
this.y = 0;
}
}
package jpwr.app;
import android.graphics.Color;
import android.graphics.Paint;
public class PlowRect implements PlowArrayElem {
PlowCmn cmn;
double x;
double y;
double width;
double height;
int borderColor;
int fillColor;
boolean fill;
boolean border;
boolean fixColor;
public PlowRect(PlowCmn cmn, double x, double y, double width, double height,
int fillColor, int borderColor, boolean fill, boolean border, boolean fixColor) {
this.cmn = cmn;
this.width = width;
this.height = height;
this.x = x;
this.y = y;
this.borderColor = borderColor;
this.fillColor = fillColor;
this.fill = fill;
this.border = border;
this.fixColor = fixColor;
}
@Override
public void draw(PlowPoint p, PlowNodeIfc node) {
if ( !fill && !border)
return;
Paint paint = new Paint();
if ( node != null && node.getInvert() && !fixColor) {
cmn.gdraw.rect(false, Plow.COLOR_BLACK, (float)((x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)((x + p.x + width) * cmn.zoom_factor - cmn.offset_x),
(float)((y + p.y + height) * cmn.zoom_factor) - cmn.offset_y);
}
else {
if ( fill) {
cmn.gdraw.rect(false, fillColor, (float)((x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)((x + p.x + width) * cmn.zoom_factor - cmn.offset_x),
(float)((y + p.y + height) * cmn.zoom_factor - cmn.offset_y));
}
if ( border) {
cmn.gdraw.rect(true, borderColor, (float)((x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)((x + p.x + width) * cmn.zoom_factor - cmn.offset_x),
(float)((y + p.y + height) * cmn.zoom_factor - cmn.offset_y));
}
}
}
@Override
public void setBorders(PlowBorders borders) {
if ( x < borders.x_left)
borders.x_left = x;
if ( x + width > borders.x_right)
borders.x_right = x + width;
if ( y < borders.y_low)
borders.y_low = y;
if ( y + height > borders.y_high)
borders.y_high = y + height;
}
public boolean eventHandler(PlowEvent e) {
return false;
}
public void setInvert(boolean invert) {
}
public void draw(double x_left, double y_low, double x_right, double y_high) {
}
}
package jpwr.app;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
public class PlowText implements PlowArrayElem {
PlowCmn cmn;
double x;
double y;
int textColor;
String text;
int size;
int font;
public PlowText(PlowCmn cmn, double x, double y, int textColor, String text,
int size, int font) {
this.cmn = cmn;
this.x = x;
this.y = y;
this.textColor = textColor;
this.text = text;
this.size = size;
this.font = font;
}
public void draw(PlowPoint p, PlowNodeIfc node) {
int textSize = (int) (cmn.zoom_factor/cmn.base_zoom_factor * size);
int color;
int font = 0;
if ( node != null && node.getInvert())
color = Plow.COLOR_WHITE;
else
color = textColor;
cmn.gdraw.drawText(text, color, textSize, font, (float)((x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((y + p.y) * cmn.zoom_factor - cmn.offset_y));
}
@Override
public void setBorders(PlowBorders borders) {
double width = 0;
double height = 0;
if ( x < borders.x_left)
borders.x_left = x;
if ( x + width > borders.x_right)
borders.x_right = x + width;
if ( y < borders.y_low)
borders.y_low = y;
if ( y + height > borders.y_high)
borders.y_high = y + height;
}
public boolean eventHandler(PlowEvent e) {
return false;
}
public void setInvert(boolean invert) {
}
public void draw(double x_left, double y_low, double x_right, double y_high) {
}
}
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
dirs : $(app_package_dir)/$(comp_name)$(dir_ext)
$(app_package_dir)/$(comp_name)$(dir_ext) :
@ echo "Create directory " $(app_package_dir)/$(comp_name)$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_package_dir)/$(comp_name)$(dir_ext)
-include ../../special.mk
-include ../special.mk
-include special.mk
include $(pwre_dir_symbols)
extern_java_sources :=
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
#
# Copy Gdh from rt_client
#
assets_dirs_fonts := ../../../fonts
assets_fonts_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(assets_dirs_fonts), \
$(wildcard $(dir)/*.ttf) \
), $(notdir $(file)) \
) \
)
assets_fonts_objects := $(addprefix $(app_assets_dir)/fonts/, $(assets_fonts_sources))
local_objects :=
dirs : $(app_assets_dir)$(dir_ext) \
$(app_assets_dir)/fonts$(dir_ext)
copy: $(assets_fonts_objects)
$(app_assets_dir)$(dir_ext) :
@ echo "Create directory " $(app_assets_dir)$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_assets_dir)$(dir_ext)
$(app_assets_dir)/fonts$(dir_ext) :
@ echo "Create directory " $(app_assets_dir)/fonts$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_assets_dir)/fonts$(dir_ext)
$(app_assets_dir)/fonts/%.ttf : ../../../../assets/fonts/%.ttf
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
-include ../../special.mk
-include ../special.mk
-include special.mk
Proview Android application PwrXtt build.
The build script java/aapp/bld/src/os_templ/hw_templ/pwrxtt_build.sh and the
make files under java/appl creates an android application tree under
$pwre_broot/os_linux/hw_x86/bld/aapp.
As some java code is shared with the web interface under java/jpwr some code is
fetched from java/jpwr/rt, java/jpwr/rt_client, java/jpwr/jopg and copied to the
application archives. The application specific code is copied from aapp/rt/src,
aapp/jopg/src, aapp/app/src and aapp/pwrxtt/src.
To build check that android is in the PATH, and if a keystore should be used,
define $pwre_keystore to point at the keystore.
Build with
> pwre build aapp bld src
Eclipse
The application PwrXtt can be imported to eclipse by stating
$pwre_sroot/os_linux/hw_x86/bld/aapp as work directory. Import the project with
File/Import/General/Existing Projects... Activate Android Tools/Fix Project Properties
in the popup menu for the project. After this the application can be run and debugged.
Any changed in the java code should be copied back to source code in java/jwpr and
java/aapp.
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
init: pwrxtt_build_init
copy: pwrxtt_build_copy
exe: pwrxtt_build_exe
pwrxtt_build_init :
@ echo "Build PwrXtt init"
@ $(pwre_sroot)/aapp/bld/src/.$(pwre_os)/.$(pwre_hw)/pwrxtt_build.sh init
pwrxtt_build_copy :
@ echo "Build PwrXtt copy"
@ $(pwre_sroot)/aapp/bld/src/.$(pwre_os)/.$(pwre_hw)/pwrxtt_build.sh copy
pwrxtt_build_exe :
@ echo "Build PwrXtt exe"
@ $(pwre_sroot)/aapp/bld/src/.$(pwre_os)/.$(pwre_hw)/pwrxtt_build.sh exe
-include ../../special.mk
-include ../special.mk
-include special.mk
#!/bin/bash
#
appname=PwrXtt
#
echo "Executing build.sh..." $PWRE_CONF_ANDROID
if [ ! "$PWRE_CONF_ANDROID" = "1" ]; then
echo "Android not installed"
exit
fi
if [ $1 = "copy" ]; then
if [ ! -e $pwre_broot/$pwre_os/$pwre_hw/bld/aapp/$appname ]; then
android create project \
--target 1 \
--name $appname \
--path $pwre_broot/$pwre_os/$pwre_hw/bld/aapp/$appname \
--activity MainActivity \
--package jpwr.pwrxtt
rm $pwre_broot/$pwre_os/$pwre_hw/bld/aapp/$appname/src/jpwr/pwrxtt/MainActivity.java
rm $pwre_broot/$pwre_os/$pwre_hw/bld/aapp/$appname/AndroidManifest.xml
rm -r $pwre_broot/$pwre_os/$pwre_hw/bld/aapp/$appname/res
fi
fi
if [ $1 = "copy" ]; then
source $pwre_bin/pwre_function
pwre build aapp manifest src
pwre build aapp pwrxtt src
pwre build aapp rt src
pwre build aapp jopg src
pwre build aapp app src
pwre build aapp res src
pwre build aapp assets src
fi
if [ $1 = "exe" ]; then
android update project \
--name $appname \
--target 1 \
--path $pwre_broot/$pwre_os/$pwre_hw/bld/aapp/$appname
cp /usr/local/android-sdk-linux/extras/android/support/v4/android-support-v4.jar \
$pwre_broot/$pwre_os/$pwre_hw/bld/aapp/$appname/libs/.
cd $pwre_broot/$pwre_os/$pwre_hw/bld/aapp/$appname
if [ -z "$pwre_keystore" ]; then
echo "pwre_keystore not defined, build debug application"
ant release
else
echo "Keystore used: $pwre_keystore"
ant release -Dkey.store=$pwre_keystore -Dkey.alias=pwrkey
fi
fi
/*
* 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 java.awt.font.*;
import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Shader;
import android.graphics.Typeface;
import android.renderscript.Font;
public class GlowDraw implements GlowDrawIfc {
boolean nodraw = true;
Typeface[] fonts = new Typeface[6];
int canvasWidth;
int canvasHeight;
Activity activity;
Canvas canvas;
Paint paint;
public GlowDraw() {
paint = new Paint();
}
public void setActivity(Activity activity) {
this.activity = activity;
fonts[0] = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL);
fonts[1] = Typeface.create(Typeface.DEFAULT, Typeface.BOLD);
fonts[2] = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL);
fonts[3] = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD);
fonts[4] = Typeface.createFromAsset(activity.getAssets(), "fonts/DroidSans.ttf");
fonts[5] = Typeface.createFromAsset(activity.getAssets(), "fonts/DroidSans-Bold.ttf");
}
public void setNodraw(boolean nodraw) {
this.nodraw = nodraw;
}
public void setCanvas(Canvas canvas) {
this.canvas = canvas;
nodraw = false;
}
public void rect(int border, int fill, double x, double y, double width, double height) {
if ( nodraw)
return;
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
canvas.drawRect((float)x, (float)y, (float)(x + width), (float)(y + height), paint);
}
public void rect(int x, int y, int width, int height, int gc_type, int idx, int highlight) {
if ( nodraw)
return;
if ( gc_type == Glow.eDrawType_LineGray && highlight != 0)
gc_type = Glow.eDrawType_Line;
int color = getColor(gc_type);
paint.setColor(color);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
canvas.drawRect((float)x, (float)y, (float)(x + width), (float)(y + height), paint);
}
public void fill_rect(int x, int y, int width, int height, int gc_type) {
if ( nodraw)
return;
int color = getColor(gc_type);
paint.setColor(color);
paint.setStyle(Paint.Style.FILL);
canvas.drawRect((float)x, (float)y, (float)(x + width), (float)(y + height), paint);
}
public void gradient_fill_rect(int x, int y, int width, int height, int gc_type, int f1, int f2, int gradient) {
if ( nodraw)
return;
setGradient( gradient, f1, f2, (float)x, (float)y, (float)width, (float)height);
paint.setStyle(Paint.Style.FILL);
canvas.drawRect((float)x, (float)y, (float)(x + width), (float)(y + height), paint);
paint.setShader(null);
}
public void gradient_fill_rectrounded(int x, int y, int width, int height, int amount, int gc_type, int f1, int f2, int gradient) {
if ( nodraw)
return;
setGradient( gradient, f1, f2, (float)x, (float)y, (float)width, (float)height);
paint.setStyle(Paint.Style.FILL);
canvas.drawRoundRect(new RectF((float)x, (float)y, (float)(x + width), (float)(y + height)), amount, amount, paint);
paint.setShader(null);
}
public void arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type, int idx, int highlight) {
if ( nodraw)
return;
if ( gc_type == Glow.eDrawType_LineGray && highlight != 0)
gc_type = Glow.eDrawType_Line;
int color = getColor(gc_type);
paint.setColor(color);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(idx+1);
canvas.drawArc(new RectF((float)x, (float)y, (float)(x + width), (float)(y + height)), (float)(360-angle1), (float)(-angle2), false, paint);
}
public void fill_arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type) {
if ( nodraw)
return;
int color = getColor(gc_type);
paint.setColor(color);
paint.setStyle(Paint.Style.FILL);
canvas.drawArc(new RectF((float)x, (float)y, (float)(x + width), (float)(y + height)), (float)(360-angle1), (float)(-angle2), false, paint);
}
public void gradient_fill_arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type, int f1, int f2, int gradient) {
if ( nodraw)
return;
setGradient( gradient, f1, f2, (float)x, (float)y, (float)width, (float)height);
paint.setStyle(Paint.Style.FILL);
canvas.drawArc(new RectF((float)x, (float)y, (float)(x + width), (float)(y + height)), (float)(360-angle1), (float)(-angle2), false, paint);
paint.setShader(null);
}
public void line(int x1, int y1, int x2, int y2, int gc_type, int idx, int highlight) {
if ( nodraw)
return;
int color = getColor(gc_type);
paint.setColor(color);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(idx+1);
canvas.drawLine(x1, y1, x2, y2, paint);
}
public void line_dashed(int x1, int y1, int x2, int y2, int gc_type, int idx, int highlight, int line_type) {
if ( nodraw)
return;
int color = getColor(gc_type);
float[] dash = null;
switch ( line_type) {
case Glow.eLineType_Solid:
break;
case Glow.eLineType_Dashed1:
dash = new float[] {(float)idx, (float)idx};
break;
case Glow.eLineType_Dashed2:
dash = new float[] {(float)idx * 2, (float)idx * 2};
break;
case Glow.eLineType_Dashed3:
dash = new float[] {(float)idx * 4, (float)idx * 4};
break;
case Glow.eLineType_Dotted:
dash = new float[] {(float)idx, (float)idx * 6};
break;
case Glow.eLineType_DotDashed1:
dash = new float[] {(float)idx * 1, (float)idx * 2, (float)idx * 4, (float)idx * 2};
break;
case Glow.eLineType_DotDashed2:
dash = new float[] {(float)idx, (float)idx * 4, (float)idx * 8, (float)idx * 4};
break;
}
paint.setColor(color);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(idx+1);
if ( dash != null && idx != 0)
paint.setPathEffect(new DashPathEffect(dash, 0));
canvas.drawLine(x1, y1, x2, y2, paint);
if ( dash != null && idx != 0)
paint.setPathEffect(null);
}
public void polyline(GlowPointX[] points, int point_cnt, int gc_type, int idx, int highlight) {
if ( nodraw)
return;
Path path = new Path();
int color = getColor(gc_type);
paint.setColor(color);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(idx+1);
path.moveTo(points[0].x, points[0].y);
for ( int i = 1; i < point_cnt; i++)
path.lineTo(points[i].x, points[i].y);
canvas.drawPath(path, paint);
}
public void fill_polyline(GlowPointX[] points, int point_cnt, int gc_type, int highlight) {
if ( nodraw)
return;
Path path = new Path();
int color = getColor(gc_type);
paint.setColor(color);
paint.setStyle(Paint.Style.FILL);
path.moveTo(points[0].x, points[0].y);
for ( int i = 1; i < point_cnt; i++)
path.lineTo(points[i].x, points[i].y);
canvas.drawPath(path, paint);
}
public void gradient_fill_polyline(GlowPointX[] points, int point_cnt, int gc_type, int f1, int f2, int gradient) {
if ( nodraw)
return;
Path path = new Path();
int x_low = points[0].x;
int x_high = points[0].x;
int y_low = points[0].y;
int y_high = points[0].y;
int color = getColor(gc_type);
paint.setColor(color);
paint.setStyle(Paint.Style.FILL);
path.moveTo(points[0].x, points[0].y);
for ( int i = 1; i < point_cnt; i++) {
path.lineTo(points[i].x, points[i].y);
if ( points[i].x > x_high)
x_high = points[i].x;
if ( points[i].x < x_low)
x_low = points[i].x;
if ( points[i].y > y_high)
y_high = points[i].y;
if ( points[i].y < y_low)
y_low = points[i].y;
}
setGradient( gradient, f1, f2, (float)x_low, (float)y_low, (float)(x_high - x_low), (float)(y_high - y_low));
canvas.drawPath(path, paint);
paint.setShader(null);
}
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;
int c = getColor(color);
if ( gc_type == Glow.eDrawType_TextHelveticaBold && (font_idx & 1) != 0)
font_idx++;
paint.setTextSize(2.1F * idx + 7);
paint.setTypeface(fonts[font_idx]);
paint.setColor(c);
paint.setStyle(Paint.Style.FILL);
canvas.drawText( text, x, y, paint);
}
public int getColor(int gc_type) {
GlowColorRgb rgb = GlowColor.rgb_color(gc_type);
return Color.rgb((int)(rgb.r * 255), (int)(rgb.g * 255), (int)(rgb.b * 255));
}
public int gradient_rotate(double rotate, int gradient) {
return gradient;
}
public void setGradient( int gradient, int f1, int f2,
float x, float y, float w, float h) {
float gx0 = 0;
float gy0 = 0;
float gx1 = 0;
float gy1 = 0;
float gr = 0;
switch ( gradient) {
case Glow.eGradient_HorizontalUp:
gx0 = x;
gy0 = y;
gx1 = x;
gy1 = y + h;
break;
case Glow.eGradient_HorizontalDown:
gx0 = x;
gy0 = y + h;
gx1 = x;
gy1 = y;
break;
case Glow.eGradient_HorizontalTube1:
gx0 = x;
gy0 = y + 0.5F * h;
gx1 = x;
gy1 = y;
break;
case Glow.eGradient_HorizontalTube2:
gx0 = x;
gy0 = y + 0.3F * h;
gx1 = x;
gy1 = y + h;
break;
case Glow.eGradient_VerticalLeft:
gx0 = x;
gy0 = y;
gx1 = x + w;
gy1 = y;
break;
case Glow.eGradient_VerticalRight:
gx0 = x + w;
gy0 = y;
gx1 = x;
gy1 = y;
break;
case Glow.eGradient_VerticalTube1:
gx0 = x + 0.5F * w;
gy0 = y;
gx1 = x;
gy1 = y;
break;
case Glow.eGradient_VerticalTube2:
gx0 = x + 0.3F * w;
gy0 = y;
gx1 = x + w;
gy1 = y;
break;
case Glow.eGradient_DiagonalUpperLeft:
gx0 = x;
gy0 = y;
gx1 = x + w;
gy1 = y + h;
break;
case Glow.eGradient_DiagonalLowerLeft:
gx0 = x;
gy0 = y + h;
gx1 = x + w;
gy1 = y;
break;
case Glow.eGradient_DiagonalUpperRight:
gx0 = x + w;
gy0 = y;
gx1 = x;
gy1 = y + h;
break;
case Glow.eGradient_DiagonalLowerRight:
gx0 = x + w;
gy0 = y + h;
gx1 = x;
gy1 = y;
break;
case Glow.eGradient_DiagonalUpTube:
gx0 = x + 0.5F * w;
gy0 = y + 0.5F * h;
gx1 = x + w;
gy1 = y + h;
break;
case Glow.eGradient_DiagonalDownTube:
gx0 = x + 0.5F * w;
gy0 = y + 0.5F * h;
gx1 = x;
gy1 = y + h;
break;
case Glow.eGradient_Globe:
gx0 = x + 0.3F * w;
gy0 = y + 0.3F * h;
gx1 = x + w;
gy1 = y + h;
gr = (float) Math.sqrt( w*w/4+h*h/4);
break;
case Glow.eGradient_RadialCenter:
gx0 = x + 0.5F * w;
gy0 = y + 0.5F * h;
gx1 = x + w;
gy1 = y + h;
gr = (float) Math.sqrt( w*w/4F+h*h/4F);
break;
case Glow.eGradient_RadialUpperLeft:
gx0 = x;
gy0 = y;
gx1 = x + w;
gy1 = y + h;
gr = (float) Math.sqrt( w*w+h*h);
break;
case Glow.eGradient_RadialLowerLeft:
gx0 = x;
gy0 = y + h;
gx1 = x + w;
gy1 = y;
gr = (float) Math.sqrt( w*w+h*h);
break;
case Glow.eGradient_RadialUpperRight:
gx0 = x + w;
gy0 = y;
gx1 = x;
gy1 = y + h;
gr = (float) Math.sqrt( w*w+h*h);
break;
case Glow.eGradient_RadialLowerRight:
gx0 = x + w;
gy0 = y + h;
gx1 = x;
gy1 = y;
gr = (float) Math.sqrt( w*w+h*h);
break;
default: ;
}
switch ( gradient) {
case Glow.eGradient_HorizontalUp:
case Glow.eGradient_HorizontalDown:
case Glow.eGradient_HorizontalTube1:
case Glow.eGradient_HorizontalTube2:
case Glow.eGradient_VerticalLeft:
case Glow.eGradient_VerticalRight:
case Glow.eGradient_VerticalTube1:
case Glow.eGradient_VerticalTube2:
case Glow.eGradient_DiagonalUpperLeft:
case Glow.eGradient_DiagonalLowerLeft:
case Glow.eGradient_DiagonalUpperRight:
case Glow.eGradient_DiagonalLowerRight:
case Glow.eGradient_DiagonalUpTube:
case Glow.eGradient_DiagonalDownTube: {
LinearGradient gp = new LinearGradient( gx0, gy0,
gx1, gy1,
getColor(f2),getColor(f1), Shader.TileMode.MIRROR);
paint.setShader(gp);
break;
}
case Glow.eGradient_Globe:
case Glow.eGradient_RadialCenter:
case Glow.eGradient_RadialUpperLeft:
case Glow.eGradient_RadialLowerLeft:
case Glow.eGradient_RadialUpperRight:
case Glow.eGradient_RadialLowerRight:{
RadialGradient gp = new RadialGradient( gx0, gy0, gr, getColor(f2), getColor(f1), Shader.TileMode.CLAMP);
paint.setShader(gp);
break;
}
default: ;
}
}
public GlowDimension getTextExtent( String text, int idx, int type, int gc_type) {
Rect bounds = new Rect();
paint.setTextSize(2.1F * idx + 7);
paint.getTextBounds(text, 0, text.length(), bounds);
GlowDimension dim = new GlowDimension();
dim.width = bounds.width();
dim.height = bounds.height();
return dim;
}
public int set_clip_rectangle( int x1, int y1, int x2, int y2) {
canvas.clipRect(x1, y1, x2, y2, Region.Op.REPLACE);
return 1;
}
public void reset_clip_rectangle() {
canvas.clipRect(0, 0, canvas.getWidth(), canvas.getHeight(), Region.Op.REPLACE);
}
}
/*
* 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 java.awt.*;
import android.graphics.Canvas;
public interface GlowDrawIfc {
public void setCanvas(Canvas canvas);
public void rect(int border, int fill, double x, double y, double witdh, double height);
public void rect(int x, int y, int width, int height, int gc_type, int idx, int highlight);
public void fill_rect(int x, int y, int width, int height, int gc_type);
public void gradient_fill_rect(int x, int y, int width, int height, int gc_type, int f1, int f2, int gradient);
public void gradient_fill_rectrounded(int x, int y, int width, int height, int amount, int gc_type, int f1, int f2, int gradient);
public void arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type, int idx, int highlight);
public void fill_arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type);
public void gradient_fill_arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type, int f1, int f2, int gradient);
public void line(int x1, int y1, int x2, int y2, int gc_type, int idx, int highlight);
public void line_dashed(int x1, int y1, int x2, int y2, int gc_type, int idx, int highlight, int line_type);
public void polyline(GlowPointX[] points, int point_cnt, int gc_type, int idx, int highlight);
public void fill_polyline(GlowPointX[] points, int point_cnt, int gc_type, int highlight);
public void gradient_fill_polyline(GlowPointX[] points, int point_cnt, int gc_type, int f1, int f2, int gradient);
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);
public int gradient_rotate(double rotate, int gradient);
public GlowDimension getTextExtent( String text, int idx, int type, int gc_type);
public int getColor(int gc_type);
public int set_clip_rectangle( int x1, int y1, int x2, int y2);
public void reset_clip_rectangle();
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* 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.awt.*;
import java.awt.font.*;
import java.net.*;
public class GrowFrame implements GraphApplIfc {
/*
JScrollPane scrollPane;
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
Dimension size;
Object root;
Graph graph;
Timer timer;
LocalPanel localPanel = new LocalPanel();
int scanTime = 1000;
int scanCount = 0;
JDialog confirmDia = null;
JLabel confirmLabel;
Object confirmDyn;
Object confirmObject;
*/
String instance;
GrowFrameApplIfc appl;
public GrowFrame( String file, Gdh gdh, String instance, GrowFrameApplIfc appl) {
/*
root = (Object) this;
this.instance = instance;
this.appl = appl;
init( file, gdh);
*/
}
private void init( String file, Gdh gdh) {
/*
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
contentPane.add(localPanel, BorderLayout.CENTER);
contentPane.setOpaque(true);
localPanel.setLayout(null);
localPanel.setOpaque(true);
localPanel.setBackground( Color.white);
this.setTitle("GrowFrame");
size = new Dimension( 1100, 900);
setSize( size);
String filename;
BufferedReader reader = null;
String fname = file;
if ( root != null && root instanceof JApplet) {
try {
URL current = ((JApplet) root).getCodeBase();
String current_str = current.toString();
int idx1 = current_str.lastIndexOf('/');
int idx2 = current_str.lastIndexOf(':');
int idx = idx1;
if ( idx2 > idx)
idx = idx2;
String path = current_str.substring(0,idx + 1);
filename = path + fname;
System.out.println( "Opening file " + filename);
URL fileURL = new URL( filename);
InputStream in = fileURL.openStream();
// in = new BufferedInputStream(in);
InputStreamReader r2 = new InputStreamReader(in);
reader = new BufferedReader( r2);
}
catch ( Exception e) {
System.out.println( "Unable to open file");
}
}
else {
if ( fname.lastIndexOf('/') == -1)
filename = "$pwrp_exe/" + fname;
else
filename = fname;
filename = Gdh.translateFilename( filename);
System.out.println( "Fname: " + filename);
try {
reader = new BufferedReader(new FileReader(filename));
}
catch ( Exception e) {
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);
}
}
if ( gdh == null)
gdh = new Gdh(this);
graph = new Graph(this, gdh);
graph.open(reader);
setSize();
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
setDefaultCloseOperation( DISPOSE_ON_CLOSE);
MouseAdapter adapter = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("MouseListener");
GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_MB1Click;
graph.ctx.eventHandler( event);
}
public void mousePressed(MouseEvent e) {
System.out.println("MouseListener");
GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_MB1Down;
graph.ctx.eventHandler( event);
}
public void mouseReleased(MouseEvent e) {
System.out.println("MouseListener");
GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_MB1Up;
graph.ctx.eventHandler( event);
}
public void mouseMoved(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_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);
localPanel.addMouseMotionListener(adapter);
timer = new Timer( scanTime, this);
timer.start();
*/
}
public int getWidth() {
//return localPanel.getWidth() + 5;
return 100;
}
public int getHeight() {
//return localPanel.getHeight() + 40;
return 100;
}
/*
public void actionPerformed( ActionEvent e) {
scanCount++;
if ( scanCount == 1)
graph.gdh.getObjectRefInfoAll();
graph.ctx.traceScan();
localPanel.repaint();
}
*/
void setSize() {
/*
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();
*/
}
/*
class LocalPanel extends JPanel {
public LocalPanel() {}
public Dimension getPreferredSize() { return size;}
public Dimension getMinimumSize() { return size;}
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setPaint(graph.ctx.cmn.gdraw.getColor(graph.ctx.cmn.background_color));
g2.fill(new Rectangle2D.Double(0,0,getWidth(),getHeight()));
graph.gdraw.setGraphics(g2);
graph.ctx.draw();
}
}
*/
public void closeGrow() {
}
public int command(String cmd) {
System.out.println("Ge command : " + cmd);
if ( appl != null)
return appl.command(cmd);
return 0;
}
public void confirmNo() {}
public void confirmYes() {
// ((Dyn)confirmDyn).confirmedAction( Glow.eEvent_MB1Click, confirmObject);
}
public void openConfirmDialog( Object dyn, String text, Object object) {
/*
JLabel label = null;
confirmDyn = dyn;
confirmObject = object;
if ( confirmDia == null) {
confirmDia = new JDialog();
confirmDia.setTitle("Confirm");
confirmDia.setResizable(false);
confirmDia.setDefaultCloseOperation( JDialog.DO_NOTHING_ON_CLOSE);
confirmDia.setSize( 400, 150);
confirmLabel = new JLabel( text, JLabel.CENTER);
confirmDia.getContentPane().setLayout( new BorderLayout());
confirmDia.getContentPane().add( confirmLabel, BorderLayout.CENTER);
JButton buttonYes = new JButton("Yes");
buttonYes.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ev) {
confirmYes();
confirmDia.dispose();
}
});
JButton buttonNo = new JButton("No");
buttonNo.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ev) {
confirmNo();
confirmDia.dispose();
}
});
JButton buttonCancel = new JButton("Cancel");
buttonCancel.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ev) {
confirmNo();
confirmDia.dispose();
}
});
JPanel panel = new JPanel();
panel.add( buttonYes);
panel.add( buttonNo);
panel.add( buttonCancel);
confirmDia.getContentPane().add( panel, BorderLayout.SOUTH);
// confirmDia.setLocationRelativeTo( par);
confirmDia.setVisible( true);
}
else {
// confirmDia.setLocationRelativeTo( par);
confirmLabel.setText( text);
confirmDia.setVisible( true);
}
*/
}
public String getObject() {
return instance;
}
}
include $(pwre_dir_symbols)
extern_java_sources := \
Glow.java,\
PrintfFormat.java,\
GlowCFormat.java,\
GlowFillLevelLimits.java,\
GlowGeometry.java,\
GlowPointX.java,\
GlowPointDX.java,\
GlowDimension.java,\
GlowSliderInfo.java,\
GlowTableInfo.java,\
GlowMenuInfo.java,\
GlowTransform.java,\
GlowEvent.java,\
GlowArrayElem.java,\
GlowPoint.java,\
GrowApplIfc.java,\
GlowColorNode.java,\
GlowColorRgb.java,\
GlowColor.java,\
GlowBackgroundObject.java,\
GlowEventMenu.java,\
GrowCtxIfc.java,\
GrowCmn.java,\
GlowNodeClass.java,\
GlowNodeGroup.java,\
GlowConClass.java,\
GlowConPoint.java,\
GrowNode.java,\
GlowLine.java,\
GlowArc.java,\
GlowArrow.java,\
GlowCon.java,\
GrowRect.java,\
GrowRectRounded.java,\
GrowGroup.java,\
GrowSlider.java,\
GrowAxis.java,\
GrowArc.java,\
GrowLine.java,\
GrowPolyline.java,\
GrowText.java,\
GrowAnnot.java,\
GrowMenu.java,\
GrowBar.java,\
GrowTrend.java,\
GrowScrollBarIfc.java,\
GrowScrollBar.java,\
GrowTable.java,\
GrowConGlue.java,\
GlowVector.java,\
GrowCtx.java,\
DynParsedAttrName.java,\
GraphLocalDb.java,\
GraphIfc.java,\
Dyn.java,\
GraphApplIfc.java,\
Graph.java,\
GrowFrameApplIfc.java
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
dirs : $(app_package_dir)/$(comp_name)$(dir_ext)
$(app_package_dir)/$(comp_name)$(dir_ext) :
@ echo "Create directory " $(app_package_dir)/$(comp_name)$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_package_dir)/$(comp_name)$(dir_ext)
-include ../../special.mk
-include ../special.mk
-include special.mk
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jpwr.pwrxtt"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="jpwr.pwrxtt.MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
local_objects := \
$(release_root)/bld/$(type_name)/$(appname)/AndroidManifest.xml \
$(release_root)/bld/$(type_name)/$(appname)/.project \
$(release_root)/bld/$(type_name)/$(appname)/.classpath
copy: $(local_objects)
$(release_root)/bld/$(type_name)/$(appname)/AndroidManifest.xml : ../../AndroidManifest.xml
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(release_root)/bld/$(type_name)/$(appname)/.project : ../../project
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(release_root)/bld/$(type_name)/$(appname)/.classpath : ../../classpath
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
-include ../../special.mk
-include ../special.mk
-include special.mk
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PwrXtt</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
package jpwr.pwrxtt;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.StringTokenizer;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentManager;
import android.text.Editable;
import android.text.InputType;
import android.util.Log;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.view.*;
import android.widget.EditText;
import android.graphics.*;
import jpwr.rt.*;
import jpwr.app.*;
import jpwr.jopg.*;
public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, GdhApplIfc, OnClickListener, AEvAppl {
Timer timer = new Timer();
MainView view;
Gdh gdh = null;
Handler handler = new Handler();
MainActivity appl;
float lastTouchX;
float lastTouchY;
float downTouchX;
float downTouchY;
private EditText editInput;
PlowDraw gdraw;
PlowCmnIfc currentCmn;
PlowRect r1;
PlowAnnot a1;
PlowAnnot a11;
PlowAnnotPixmap p1;
PlowNode zoomIn;
PlowNode zoomOut;
String inputFullName;
Graph graph = null;
Vector<String> graphObject = new Vector<String>();
int inputType;
AlertDialog inputDialog = null;
static private boolean initDone = false;
String pwrHost = null;
AEv aev = null;
Vector<PlowCmnIfc> cmnList = new Vector<PlowCmnIfc>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
appl = this;
view = new MainView(this);
setContentView(view);
Log.i("PwrXtt", "Starting");
view.invalidate();
timer.schedule( new MyTask(), 0, 2000);
PlowCmn cmn = new PlowCmn(this, 15D);
gdraw = new PlowDraw(this);
cmn.setGDraw(gdraw);
currentCmn = cmn;
cmnList.add(cmn);
editInput = new EditText(this);
editInput.setText("10.0.2.2");
new AlertDialog.Builder(this)
.setTitle(R.string.app_name)
.setMessage("Enter target node")
.setView(editInput)
.setPositiveButton("Ok", this)
.setNegativeButton("Cancel", null)
.show();
}
public void onClick(DialogInterface dialog, int position) {
if ( dialog == inputDialog) {
Editable value = editInput.getText();
System.out.println( "Change Value: " + value.toString());
new GdhTask().execute(new GdhTaskArg(GdhTask.CHANGE_VALUE, value.toString()));
}
else {
Editable value = editInput.getText();
pwrHost = value.toString();
System.out.println( "Input: " + value.toString());
//MainActivity callingActivity = (MainActivity) this;
//callingActivity.onUserSelectValue(value);
dialog.dismiss();
new GdhTask().execute(new GdhTaskArg(GdhTask.ROOTLIST,(AXttItemBase)null));
}
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
view.invalidate();
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem item_pageup = menu.findItem(R.id.pageup_option);
MenuItem item_pagedown = menu.findItem(R.id.pagedown_option);
MenuItem item_openobject = menu.findItem(R.id.openobject_option);
MenuItem item_opengraph = menu.findItem(R.id.opengraph_option);
MenuItem item_openclassgraph = menu.findItem(R.id.openclassgraph_option);
MenuItem item_openplc = menu.findItem(R.id.openplc_option);
MenuItem item_opencrr = menu.findItem(R.id.opencrr_option);
MenuItem item_alarmack = menu.findItem(R.id.alarmack_option);
MenuItem item_changevalue = menu.findItem(R.id.changevalue_option);
if ( aev != null && currentCmn == aev.getCmnAla()) {
// Alarm list
item_pageup.setVisible(true);
item_pagedown.setVisible(true);
item_openobject.setVisible(true);
item_opengraph.setVisible(true);
item_openclassgraph.setVisible(true);
item_openplc.setVisible(true);
item_opencrr.setVisible(true);
item_alarmack.setVisible(true);
item_changevalue.setVisible(false);
}
else if ( aev != null && currentCmn == aev.getCmnEve()) {
// Event list
item_pageup.setVisible(true);
item_pagedown.setVisible(true);
item_openobject.setVisible(true);
item_opengraph.setVisible(true);
item_openclassgraph.setVisible(true);
item_openplc.setVisible(true);
item_opencrr.setVisible(true);
item_alarmack.setVisible(false);
item_changevalue.setVisible(false);
}
else if ( currentCmn == cmnList.get(0)) {
// Navigator
item_pageup.setVisible(true);
item_pagedown.setVisible(true);
item_openobject.setVisible(true);
item_opengraph.setVisible(true);
item_openclassgraph.setVisible(true);
item_openplc.setVisible(true);
item_opencrr.setVisible(true);
item_alarmack.setVisible(false);
item_changevalue.setVisible(true);
}
else if ( currentCmn.type() == PlowCmnIfc.TYPE_FLOW) {
// Plc
item_pageup.setVisible(true);
item_pagedown.setVisible(true);
item_openobject.setVisible(true);
item_opengraph.setVisible(true);
item_openclassgraph.setVisible(true);
item_openplc.setVisible(true);
item_opencrr.setVisible(true);
item_alarmack.setVisible(false);
item_changevalue.setVisible(false);
}
else if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) {
// Graph
item_pageup.setVisible(false);
item_pagedown.setVisible(false);
item_openobject.setVisible(false);
item_opengraph.setVisible(false);
item_openclassgraph.setVisible(false);
item_openplc.setVisible(false);
item_opencrr.setVisible(false);
item_alarmack.setVisible(false);
item_changevalue.setVisible(false);
}
else {
// Default
item_pageup.setVisible(true);
item_pagedown.setVisible(true);
item_openobject.setVisible(true);
item_opengraph.setVisible(true);
item_openclassgraph.setVisible(true);
item_openplc.setVisible(true);
item_opencrr.setVisible(true);
item_alarmack.setVisible(false);
item_changevalue.setVisible(false);
}
// this.invalidateOptionsMenu();
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch( item.getItemId()) {
case R.id.zoomin_option:
currentCmn.zoom(1.25D);
view.invalidate();
System.out.println("Zoom in");
break;
case R.id.zoomout_option:
currentCmn.zoom(0.8D);
view.invalidate();
System.out.println("Zoom in");
break;
case R.id.pageup_option:
currentCmn.pageUp();
view.invalidate();
System.out.println("Page up");
break;
case R.id.pagedown_option:
currentCmn.pageDown();
view.invalidate();
System.out.println("Page down");
break;
case R.id.close_option:
switch(currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW: {
if ( cmnList.size() == 1) {
// TODO Close application
break;
}
PlowCmn cmn = (PlowCmn)currentCmn;
AXtt axtt = (AXtt)currentCmn.getUserData();
PlowNode o = (PlowNode)cmn.get(0);
AXttItemObject itemo = (AXttItemObject)o.getUserData();
itemo.close(axtt);
currentCmn = cmnList.get(cmnList.size()-2);
cmnList.removeElementAt(cmnList.size()-1);
System.out.println( "cmnList.size() " + cmnList.size());
view.invalidate();
break;
}
case PlowCmnIfc.TYPE_FLOW:
new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_CLOSE, currentCmn));
System.out.println( "cmnList.size() " + cmnList.size());
currentCmn = cmnList.get(cmnList.size()-2);
cmnList.removeElementAt(cmnList.size()-1);
System.out.println( "cmnList.size() " + cmnList.size());
view.invalidate();
System.out.println("Close flow");
break;
case PlowCmnIfc.TYPE_EV:
System.out.println( "cmnList.size() " + cmnList.size());
currentCmn = cmnList.get(cmnList.size()-1);
aev = null;
view.invalidate();
System.out.println("Close ev");
break;
case PlowCmnIfc.TYPE_GRAPH:
new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_CLOSE, currentCmn));
System.out.println( "cmnList.size() " + cmnList.size());
if (graphObject.size() > 0)
graphObject.removeElementAt(graphObject.size()-1);
currentCmn = cmnList.get(cmnList.size()-2);
cmnList.removeElementAt(cmnList.size()-1);
System.out.println( "cmnList.size() " + cmnList.size());
view.invalidate();
System.out.println("Close graph");
break;
}
break;
case R.id.openobject_option: {
System.out.println("Open object");
switch (currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW: {
PlowNode selectedNode = (PlowNode)currentCmn.getSelect();
if ( selectedNode != null) {
AXttItemBase[] items = new AXttItemBase[1];
AXttItemBase baseItem = (AXttItemBase)selectedNode.getUserData();
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_ATTRIBUTES, baseItem));
}
break;
}
case PlowCmnIfc.TYPE_FLOW: {
FlowNode selectedNode = (FlowNode)currentCmn.getSelect();
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_FLOWNODE, selectedNode));
break;
}
}
break;
}
case R.id.opencrr_option: {
System.out.println("Open object");
switch (currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW: {
PlowNode selectedNode = (PlowNode)currentCmn.getSelect();
if ( selectedNode != null) {
AXttItemBase[] items = new AXttItemBase[1];
AXttItemBase baseItem = (AXttItemBase)selectedNode.getUserData();
new GdhTask().execute(new GdhTaskArg(GdhTask.CROSSREFERENCES, baseItem));
}
break;
}
case PlowCmnIfc.TYPE_FLOW: {
FlowNode selectedNode = (FlowNode)currentCmn.getSelect();
if ( selectedNode != null) {
new GdhTask().execute(new GdhTaskArg(GdhTask.FLOW_CROSSREFERENCE, selectedNode));
}
break;
}
}
break;
}
case R.id.openplc_option: {
System.out.println("Open plc");
switch (currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW: {
PlowNode selectedNode = (PlowNode)currentCmn.getSelect();
if ( selectedNode != null) {
AXttItemBase baseItem = (AXttItemBase)selectedNode.getUserData();
if ( baseItem instanceof AXttItemObject) {
if (((AXttItemObject)baseItem).getClassid() == Pwrb.cClass_plc) {
PwrtObjid woid = ((AXttItemObject)baseItem).getWindowObjid();
new ReaderTask().execute(new ReaderTaskArg(ReaderTask.FLOW_READ, woid, null));
}
else {
PwrtObjid oid = ((AXttItemObject)baseItem).getObjid();
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_FLOW, oid));
}
}
else if ( baseItem instanceof AXttItemCrr) {
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_FLOWCROSS, baseItem));
}
}
break;
}
case PlowCmnIfc.TYPE_FLOW: {
FlowNode selectedNode = (FlowNode)currentCmn.getSelect();
if ( selectedNode != null) {
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_FLOWSUBWINDOW, selectedNode));
System.out.println("Open object");
}
break;
}
}
break;
}
case R.id.opengraph_option: {
System.out.println("Open graph");
switch (currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW: {
PlowNode selectedNode = (PlowNode)currentCmn.getSelect();
if ( selectedNode != null) {
AXttItemBase baseItem = (AXttItemBase)selectedNode.getUserData();
if ( baseItem instanceof AXttItemObject) {
PwrtObjid oid = ((AXttItemObject)baseItem).getObjid();
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_DEFGRAPH, oid));
}
}
break;
}
case PlowCmnIfc.TYPE_FLOW: {
break;
}
}
break;
}
case R.id.openclassgraph_option: {
System.out.println("Open Object graph " + currentCmn.type());
switch (currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW: {
PlowNode selectedNode = (PlowNode)currentCmn.getSelect();
if ( selectedNode != null) {
AXttItemBase baseItem = (AXttItemBase)selectedNode.getUserData();
if ( baseItem instanceof AXttItemObject) {
PwrtAttrRef aref = new PwrtAttrRef(((AXttItemObject)baseItem).getObjid());
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_CLASSGRAPH, aref));
}
}
break;
}
case PlowCmnIfc.TYPE_FLOW: {
break;
}
}
break;
}
case R.id.changevalue_option: {
System.out.println("Change value");
switch (currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW: {
PlowNode selectedNode = (PlowNode)currentCmn.getSelect();
if ( selectedNode != null) {
AXttItemBase baseItem = (AXttItemBase)selectedNode.getUserData();
if ( baseItem instanceof AXttItemAttr) {
inputFullName = ((AXttItemAttr)baseItem).getFullName();
inputType = ((AXttItemAttr)baseItem).getType();
editInput = new EditText(this);
inputDialog = new AlertDialog.Builder(this)
.setTitle(R.string.app_name)
.setMessage("Change Value")
.setView(editInput)
.setPositiveButton("Ok", this)
.setNegativeButton("Cancel", null)
.show();
}
}
break;
}
}
break;
}
case R.id.alarmlist_option: {
System.out.println("Open Alarmlist");
if ( aev == null) {
PlowCmnEv cmnAla = new PlowCmnEv(appl, 15D);
cmnAla.setGDraw(gdraw);
PlowCmnEv cmnEve = new PlowCmnEv(appl, 15D);
cmnEve.setGDraw(gdraw);
currentCmn = cmnAla;
aev = new AEv(cmnAla, cmnEve, appl);
cmnAla.setUserData(aev);
cmnEve.setUserData(aev);
view.invalidate();
}
else {
currentCmn = aev.getCmnAla();
view.invalidate();
}
break;
}
case R.id.eventlist_option: {
System.out.println("Open Eventlist");
if ( aev == null) {
PlowCmnEv cmnAla = new PlowCmnEv(appl, 15D);
cmnAla.setGDraw(gdraw);
PlowCmnEv cmnEve = new PlowCmnEv(appl, 15D);
cmnEve.setGDraw(gdraw);
currentCmn = cmnEve;
aev = new AEv(cmnAla, cmnEve, appl);
cmnAla.setUserData(aev);
cmnEve.setUserData(aev);
view.invalidate();
}
else {
currentCmn = aev.getCmnEve();
view.invalidate();
}
break;
}
case R.id.alarmack_option: {
if ( aev != null && currentCmn == aev.getCmnAla()) {
aev.acknowledge();
view.invalidate();
}
else {
currentCmn = aev.getCmnEve();
view.invalidate();
}
break;
}
}
return true;
}
public void eventHandler(PlowEvent e) {
switch (e.type) {
case PlowEvent.TYPE_CLICK:
if ( e.object == null)
return;
switch(currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW:
if ( e.inIcon) {
// Open children
System.out.println("Click event");
AXttItemBase[] items = new AXttItemBase[1];
AXttItemBase item = (AXttItemBase)((PlowNode)e.object).getUserData();
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_CHILDREN, item));
}
else {
// Select
if ( currentCmn.getSelect() == e.object) {
currentCmn.select(null);
((PlowNode)e.object).setInvert(false);
//view.invalidate();
}
else {
if ( currentCmn.getSelect() != null)
((PlowNode)currentCmn.getSelect()).setInvert(false);
currentCmn.select((PlowNode)e.object);
((PlowNode)e.object).setInvert(true);
//view.invalidate();
}
}
break;
case PlowCmnIfc.TYPE_EV:
// Select
if ( currentCmn.getSelect() == e.object) {
currentCmn.select(null);
((PlowNode)e.object).setInvert(false);
//view.invalidate();
}
else {
if ( currentCmn.getSelect() != null)
((PlowNode)currentCmn.getSelect()).setInvert(false);
currentCmn.select((PlowNode)e.object);
((PlowNode)e.object).setInvert(true);
//view.invalidate();
}
break;
case PlowCmnIfc.TYPE_FLOW:
if (e.object instanceof FlowNode) {
Object s = currentCmn.getSelect();
if ( s == e.object) {
((FlowNode)e.object).setSelect(false);
currentCmn.selectClear();
view.invalidate();
}
else if ( s != null) {
((FlowNode)s).setSelect(false);
((FlowNode)e.object).setSelect(true);
currentCmn.select(e.object);
view.invalidate();
}
else {
((FlowNode)e.object).setSelect(true);
currentCmn.select(e.object);
view.invalidate();
}
}
break;
}
break;
case PlowEvent.TYPE_OBJECT_DELETED: {
AXtt axtt = (AXtt)currentCmn.getUserData();
AXttItemBase item = (AXttItemBase)((PlowNode)e.object).getUserData();
if ( item instanceof AXttItemAttr) {
((AXttItemAttr)item).close(axtt);
}
else if ( item instanceof AXttItemAttrArrayElem) {
((AXttItemAttrArrayElem)item).close(axtt);
}
break;
}
}
}
private class GdhTaskArg {
int action;
Object item;
public GdhTaskArg(int action, Object item) {
this.action = action;
this.item = item;
}
}
private class GdhEventArg {
int action;
float x;
float y;
public GdhEventArg(int action, float x, float y) {
this.action = action;
this.x = x;
this.y = y;
}
}
private class GdhTask extends AsyncTask<GdhTaskArg, Void, Void> {
public static final int ROOTLIST = 1;
public static final int SCAN = 2;
public static final int OPEN_CHILDREN = 3;
public static final int OPEN_ATTRIBUTES = 4;
public static final int DYNAMIC_OPEN = 5;
public static final int DYNAMIC_CLOSE = 6;
public static final int DYNAMIC_UPDATE = 7;
public static final int OPEN_FLOWNODE = 8;
public static final int CROSSREFERENCES = 9;
public static final int OPEN_FLOWSUBWINDOW = 10;
public static final int OPEN_FLOW = 11;
public static final int OPEN_FLOWCROSS = 12;
public static final int FLOW_CROSSREFERENCE = 13;
public static final int CHANGE_VALUE = 14;
public static final int OPEN_DEFGRAPH = 15;
public static final int EVENTHANDLER = 16;
public static final int OPEN_CLASSGRAPH = 17;
public static final int OPEN_CLASSGRAPH_NAME = 18;
@Override
protected Void doInBackground(GdhTaskArg... arg) {
if ( gdh == null) {
gdh = new Gdh(appl);
AXtt axtt = new AXtt((PlowCmn)currentCmn, gdh);
currentCmn.setUserData(axtt);
gdh.refObjectInfoList();
}
switch ( arg[0].action) {
case ROOTLIST: {
AXtt axtt = (AXtt)currentCmn.getUserData();
System.out.println("Open rootlist");
AXttItemObject.openRoot(axtt);
currentCmn.configure();
initDone = true;
break;
}
case SCAN: {
if ( currentCmn.type() != PlowCmnIfc.TYPE_PLOW)
break;
PlowCmn cmn = (PlowCmn)currentCmn;
AXtt axtt = (AXtt)currentCmn.getUserData();
gdh.getObjectRefInfoAll();
for ( int i = 0; i < cmn.size(); i++) {
AXttItemBase bitem = (AXttItemBase)((PlowNode)cmn.get(i)).getUserData();
if ( bitem instanceof AXttItemAttr) {
((AXttItemAttr)bitem).scan(axtt);
}
else if ( bitem instanceof AXttItemAttrArrayElem) {
((AXttItemAttrArrayElem)bitem).scan(axtt);
}
}
break;
}
case OPEN_CHILDREN: {
AXtt axtt = (AXtt)currentCmn.getUserData();
if (((AXttItemBase)arg[0].item).hasChildren())
((AXttItemBase)arg[0].item).openChildren(axtt);
else
((AXttItemBase)arg[0].item).openAttributes(axtt);
currentCmn.configure();
break;
}
case OPEN_ATTRIBUTES: {
AXtt axtt = (AXtt)currentCmn.getUserData();
((AXttItemBase)arg[0].item).openAttributes(axtt);
currentCmn.configure();
break;
}
case CROSSREFERENCES: {
AXtt axtt = (AXtt)currentCmn.getUserData();
((AXttItemBase)arg[0].item).openCrossreferences(axtt);
currentCmn.configure();
break;
}
case DYNAMIC_OPEN:
((FlowCmn)currentCmn).dynamicOpen();
break;
case DYNAMIC_CLOSE:
((PlowCmnIfc)arg[0].item).dynamicClose();
break;
case DYNAMIC_UPDATE:
gdh.getObjectRefInfoAll();
currentCmn.dynamicUpdate();
break;
case OPEN_FLOWNODE: {
FlowNode node = (FlowNode)arg[0].item;
String oName = node.getTraceObject();
CdhrObjid oret = gdh.nameToObjid(oName);
PlowCmn cmn = new PlowCmn(appl, 15D);
cmn.setGDraw(gdraw);
currentCmn = cmn;
cmnList.add(cmn);
AXtt axtt = new AXtt((PlowCmn)currentCmn, gdh);
cmn.setUserData(axtt);
AXttItemObject o = new AXttItemObject(axtt, oret.objid, oName, false, null, Plow.DEST_INTOLAST);
o.openAttributes(axtt);
break;
}
case OPEN_FLOWSUBWINDOW: {
// Open flow file for first child
FlowNode node = (FlowNode)arg[0].item;
PwrtObjid nodeObjid = node.getCmn().getObjid();
CdhrString rName = gdh.objidToName(nodeObjid, Cdh.mName_pathStrict);
if (rName.evenSts())
break;
String name = rName.str + "-" + node.getName();
System.out.println( "Open flow: " + name);
CdhrObjid oret = gdh.nameToObjid(name);
if ( oret.evenSts()) break;
oret = gdh.getChild(oret.objid);
if ( oret.evenSts()) break;
new ReaderTask().execute(new ReaderTaskArg(ReaderTask.FLOW_READ, oret.objid, null));
break;
}
case OPEN_FLOW: {
// If plc window open flow for window, else for first child
PwrtObjid oid = (PwrtObjid)arg[0].item;
CdhrClassId retCid = gdh.getObjectClass(oid);
if ( retCid.evenSts())
break;
if ( !(retCid.classId == Pwrb.cClass_windowplc ||
retCid.classId == Pwrb.cClass_windoworderact ||
retCid.classId == Pwrb.cClass_windowcond ||
retCid.classId == Pwrb.cClass_windowsubstep)) {
CdhrObjid oret = gdh.getChild(oid);
if (oret.evenSts()) break;
oid = oret.objid;
}
new ReaderTask().execute(new ReaderTaskArg(ReaderTask.FLOW_READ, oid, null));
break;
}
case OPEN_FLOWCROSS: {
// If plc window open flow for window, else for first child
AXttItemCrr crr = (AXttItemCrr)arg[0].item;
String text = crr.getText();
int idx = text.indexOf(' ');
if ( idx < 0) break;
text = text.substring(0, idx);
idx = text.lastIndexOf('-');
if ( idx < 0) break;
String wname = text.substring(0, idx);
String oname = text.substring(idx+1);
System.out.println( "wname: " + wname + " oname: " + oname);
CdhrObjid oret = gdh.nameToObjid(wname);
if ( oret.evenSts()) break;
new ReaderTask().execute(new ReaderTaskArg(ReaderTask.FLOW_READ, oret.objid, oname));
break;
}
case FLOW_CROSSREFERENCE: {
FlowNode node = (FlowNode)arg[0].item;
String oName = node.getTraceObject();
CdhrObjid oret = gdh.nameToObjid(oName);
PlowCmn cmn = new PlowCmn(appl, 15D);
cmn.setGDraw(gdraw);
currentCmn = cmn;
cmnList.add(cmn);
AXtt axtt = new AXtt((PlowCmn)currentCmn, gdh);
cmn.setUserData(axtt);
AXttItemObject o = new AXttItemObject(axtt, oret.objid, oName, false, null, Plow.DEST_INTOLAST);
o.openCrossreferences(axtt);
currentCmn.configure();
break;
}
case CHANGE_VALUE: {
switch ( inputType) {
case Pwr.eType_Boolean: {
boolean bval;
if ( ((String)arg[0].item).equals("1"))
bval = true;
else if ( ((String)arg[0].item).equals("0"))
bval = false;
else
break;
PwrtStatus sts = gdh.setObjectInfo(inputFullName, bval);
if ( sts.evenSts())
System.out.println( "setObjectInfo " + sts.getSts() + " " + inputFullName);
break;
}
case Pwr.eType_Float64:
case Pwr.eType_Float32: {
float fval;
try {
fval = Float.parseFloat((String)arg[0].item);
}
catch ( NumberFormatException e) {
break;
}
PwrtStatus sts = gdh.setObjectInfo(inputFullName, fval);
if ( sts.evenSts())
System.out.println( "setObjectInfo " + sts.getSts() + " " + inputFullName);
break;
}
case Pwr.eType_Int64:
case Pwr.eType_Int32:
case Pwr.eType_Int16:
case Pwr.eType_Int8:
case Pwr.eType_UInt64:
case Pwr.eType_UInt32:
case Pwr.eType_UInt16:
case Pwr.eType_UInt8: {
int ival;
try {
ival = Integer.parseInt((String)arg[0].item);
}
catch ( NumberFormatException e) {
break;
}
PwrtStatus sts = gdh.setObjectInfo(inputFullName, ival);
if ( sts.evenSts())
System.out.println( "setObjectInfo " + sts.getSts() + " " + inputFullName);
break;
}
default: {
PwrtStatus sts = gdh.setObjectInfo(inputFullName, (String)arg[0].item);
if ( sts.evenSts())
System.out.println( "setObjectInfo " + sts.getSts() + " " + inputFullName);
}
}
break;
}
case OPEN_DEFGRAPH: {
PwrtObjid oid = (PwrtObjid)arg[0].item;
CdhrString rName = gdh.objidToName(oid, Cdh.mName_pathStrict);
if (rName.evenSts())
break;
String name = rName.str + ".DefGraph";
rName = gdh.getObjectInfoString(name);
if (rName.evenSts())
break;
String oname = rName.str;
name = oname + ".Action";
rName = gdh.getObjectInfoString(name);
if (rName.evenSts())
break;
String action = rName.str;
name = oname + ".Object";
rName = gdh.getObjectInfoString(name);
if (rName.evenSts())
break;
String instance = rName.str;
if ( instance.equals(""))
instance = null;
System.out.println("Open " + rName.str);
new ReaderTask().execute(new ReaderTaskArg(ReaderTask.GROW_READ, action, instance));
break;
}
case OPEN_CLASSGRAPH_NAME: {
CdhrAttrRef aret = gdh.nameToAttrRef((String)arg[0].item);
System.out.println("Classname " + (String)arg[0].item + " sts " + aret.getSts());
if ( aret.evenSts())
break;
arg[0].item = new PwrtAttrRef(aret.aref.objid, aret.aref.body, aret.aref.offset, aret.aref.size, aret.aref.flags);
// No break, continue with OPEN_CLASSGRAPH
}
case OPEN_CLASSGRAPH: {
PwrtAttrRef aref = (PwrtAttrRef)arg[0].item;
CdhrTypeId cret = gdh.getAttrRefTid(aref);
System.out.println("Classgraph type " + cret.getSts());
if (cret.evenSts()) break;
CdhrObjid coidret = gdh.classIdToObjid(cret.typeId);
if ( coidret.evenSts()) break;
CdhrString cnameret = gdh.objidToName(coidret.objid, Cdh.mName_object);
if (cnameret.evenSts()) break;
String classname = cnameret.str.toLowerCase();
if ( classname.startsWith("$"))
classname = classname.substring(1);
// Get GraphConfiguration if any
CdhrString nret = gdh.attrRefToName(aref, Cdh.mName_volumeStrict);
if ( nret.evenSts()) break;
String suffix = "";
CdhrInt gcret = gdh.getObjectInfoInt(nret.str + ".GraphConfiguration");
if (gcret.oddSts()) {
if ( gcret.value > 0)
suffix = Integer.toString(gcret.value);
}
String fname;
if ( coidret.objid.vid < Cdh.cUserClassVolMin ||
(coidret.objid.vid >= Cdh.cManufactClassVolMin &&
coidret.objid.vid <= Cdh.cManufactClassVolMax)) {
// Add pwr_c_ to filename
fname = "$pwr_exe/pwr_c_" + classname + suffix + ".pwg";
}
else
fname = classname + suffix + ".pwg";
CdhrString rName = gdh.attrRefToName(aref, Cdh.mName_pathStrict);
if (rName.evenSts())
break;
System.out.println("Open " + fname);
new ReaderTask().execute(new ReaderTaskArg(ReaderTask.GROW_READ, fname, rName.str));
break;
}
case EVENTHANDLER: {
GdhEventArg event = (GdhEventArg)arg[0].item;
currentCmn.eventHandler(event.action, event.x, event.y);
break;
}
}
return null;
}
@Override
protected void onPostExecute(Void params) {
super.onPostExecute(params);
view.invalidate();
}
}
private class ReaderTaskArg {
int action;
Object data1;
Object data2;
public ReaderTaskArg(int action, Object data1, Object data2) {
this.action = action;
this.data1 = data1;
this.data2 = data2;
}
}
private class ReaderTask extends AsyncTask<ReaderTaskArg, Void, Void> {
public static final int FLOW_READ = 1;
public static final int CRR_READ = 2;
public static final int GROW_READ = 3;
@Override
protected Void doInBackground(ReaderTaskArg... arg) {
switch ( arg[0].action) {
case FLOW_READ:
readFlow((PwrtObjid)arg[0].data1, (String)arg[0].data2);
break;
case GROW_READ:
readGrow((String)arg[0].data1, (String)arg[0].data2);
break;
}
return null;
}
@Override
protected void onPostExecute(Void params) {
super.onPostExecute(params);
//cmn.draw();
view.invalidate();
}
}
public Resources getApplResources() {
return getResources();
}
@Override
public boolean onTouchEvent(MotionEvent me) {
int viewOffset = 80;
int action = me.getAction();
float x = me.getX();
float y = me.getY();
switch (action) {
case MotionEvent.ACTION_MOVE:
System.out.println("Event Move " + action + " (" + x + "," + y + ")");
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH){
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_MOVE, x, y-viewOffset)));
}
else {
if ( (int)(lastTouchY - y) != 0) {
currentCmn.scroll((int)(lastTouchX -x), (int)(lastTouchY - y));
view.invalidate();
}
lastTouchX = x;
lastTouchY = y;
}
break;
case MotionEvent.ACTION_UP:
if ( currentCmn != null && currentCmn.type() == PlowCmnIfc.TYPE_GRAPH){
System.out.println("Event Up " + action + " (" + x + "," + y + ") cmn " + currentCmn.type());
if ( Math.abs(x - downTouchX) < 10 && Math.abs(y - downTouchY) < 10 &&
me.getEventTime() - me.getDownTime() < 700) {
System.out.println("Event Click " + action + " (" + x + "," + y + ") cmn " + currentCmn.type());
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_CLICK, x, y-viewOffset)));
}
else {
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_UP, x, y-viewOffset)));
}
}
else {
if ( Math.abs(x - downTouchX) < 10 && Math.abs(y - downTouchY) < 10 && currentCmn != null) {
currentCmn.eventHandler(action, x, y-viewOffset);
}
}
break;
case MotionEvent.ACTION_DOWN:
System.out.println("Event Down " + action + " (" + x + "," + y + ")");
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH){
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_DOWN, x, y-viewOffset)));
}
lastTouchX = x;
lastTouchY = y;
downTouchX = x;
downTouchY = y;
break;
}
return true;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
public void forceError() {
if (true) {
throw new Error("Whooops");
}
}
private class MainView extends SurfaceView {
Bitmap bitmap = null;
Canvas drawCanvas;
public MainView(Context context) {
super(context);
setWillNotDraw(false);
}
@Override
protected void onDraw( Canvas canvas) {
if ( currentCmn != null) {
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) {
if ( bitmap == null) {
bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
drawCanvas = new Canvas(bitmap);
drawCanvas.drawColor(graph.cmn.gdraw.getColor(graph.cmn.background_color));
}
currentCmn.setCanvas(drawCanvas);
drawCanvas.drawColor(graph.cmn.gdraw.getColor(graph.cmn.background_color));
currentCmn.draw();
canvas.drawBitmap(bitmap, 0F, 0F, null);
}
else {
Canvas c = getHolder().lockCanvas();
if ( c != null) {
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH)
c.drawColor(graph.cmn.gdraw.getColor(graph.cmn.background_color));
else
c.drawColor(Color.WHITE);
currentCmn.setCanvas(c);
currentCmn.draw();
getHolder().unlockCanvasAndPost(c);
}
}
}
}
}
class MyTask extends TimerTask {
@Override
public void run() {
runOnUiThread( new Runnable() {
public void run() {
if ( !initDone)
return;
System.out.println("MainActivity TimerTask " + currentCmn.type());
switch(currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW:
new GdhTask().execute(new GdhTaskArg(GdhTask.SCAN,
(AXttItemBase)null));
view.invalidate();
break;
case PlowCmnIfc.TYPE_FLOW:
case PlowCmnIfc.TYPE_GRAPH:
new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_UPDATE,(AXttItemBase)null));
view.invalidate();
break;
case PlowCmnIfc.TYPE_EV:
view.invalidate();
break;
}
}});
}
}
public void readFlow( PwrtObjid windowObjid, String object) {
/*
AssetManager am = getAssets();
InputStream inputStream;
try {
inputStream = am.open(filename);
}
catch ( IOException e ) {
System.out.println( "Unable to open file " + filename);
return;
}
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
*/
String filename = Flow.getFileName(windowObjid);
BufferedReader reader;
URL url = null;
try {
// url = new URL("http://10.0.2.2/data0/pwrp/opg7/bld/common/load/" + filename);
url = new URL("http://" + pwrHost + "/pwrp_load/" + filename);
reader = new BufferedReader(new InputStreamReader(url.openStream()));
} catch ( IOException e) {
System.out.println( "Unable to open file " + filename + " " + url);
return;
}
FlowCmn fcmn = new FlowCmn(this, gdh, windowObjid);
currentCmn = fcmn;
cmnList.add(fcmn);
fcmn.setGDraw(gdraw);
FlowCtx ctx = new FlowCtx(fcmn);
ctx.open(reader);
if ( object != null) {
FlowNode node = (FlowNode)ctx.getObject(object);
fcmn.select(node);
node.setSelect(true);
ctx.centerObject(node);
}
new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_OPEN, null));
}
public void readGrow( String file, String instance) {
/*
AssetManager am = getAssets();
InputStream inputStream;
try {
inputStream = am.open(filename);
}
catch ( IOException e ) {
System.out.println( "Unable to open file " + filename);
return;
}
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
*/
String filename = file;
BufferedReader reader;
URL url = null;
try {
if ( filename.startsWith("$pwr_exe/")) {
// url = new URL("http://10.0.2.2/data0/x4-8-6/rls/os_linux/hw_x86/exp/exe/" + filename.substring(9));
url = new URL("http://" + pwrHost + "/pwr_exe/" + filename.substring(9));
}
else {
// url = new URL("http://10.0.2.2/data0/pwrp/opg7/bld/x86_linux/exe/" + filename);
url = new URL("http://" + pwrHost + "/pwrp_exe/" + filename);
}
reader = new BufferedReader(new InputStreamReader(url.openStream()));
} catch ( IOException e) {
System.out.println( "Unable to open file " + filename + " " + url);
return;
}
graph = new Graph(this, gdh);
graphObject.add(instance);
graph.open(reader);
graph.gdraw.setActivity(this);
GraphCmn cmn = new GraphCmn(graph);
currentCmn = cmn;
cmnList.add(cmn);
// new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_OPEN, null));
}
// GraphApplIfc interface
public void openConfirmDialog( Object dyn, String text, Object object) {
// TODO
}
public int getWidth() {
return 500;
}
public int getHeight() {
return 500;
}
public String getObject() {
if ( graphObject.size() > 0)
return graphObject.get(graphObject.size()-1);
else
return null;
}
static CliTable[] cliTable = new CliTable[] {
new CliTable( "OPEN", new String[] {"cli_arg1", "cli_arg2", "/NAME",
"/FILE", "/SCROLLBAR", "/WIDTH", "/HEIGHT", "/MENU", "/NAVIGATOR",
"/CENTER", "/OBJECT", "/INSTANCE", "/NEW", "/CLASSGRAPH", "/ACCESS", "/PARENT"}),
new CliTable( "EXIT", null),
new CliTable( "HELP", new String[] {"cli_arg1", "cli_arg2", "cli_arg3",
"cli_arg4", "/HELPFILE", "/POPNAVIGATOR", "/BOOKMARK", "/INDEX",
"/BASE", "/RETURNCOMMAND", "/WIDTH", "/HEIGHT", "/VERSION"}),
new CliTable( "SET", new String[] {"cli_arg1",
"/NAME", "/VALUE", "/BYPASS"}),
new CliTable( "EXAMPLE", new String[] {"/NAME", "/HIERARCHY"}),
new CliTable( "CHECK", new String[] {"cli_arg1", "/METHOD", "/OBJECT"}),
new CliTable( "CALL", new String[] {"cli_arg1", "/METHOD", "/OBJECT"}),
new CliTable( "SET", new String[] {"cli_arg1", "dcli_arg2"})
};
public int command(String cmd) {
System.out.println("Command: " + cmd);
boolean local_cmd = false;
Cli cli = new Cli( cliTable);
String command = cli.parse( cmd);
if (cli.oddSts()) {
System.out.println("JopSpider1 : " + command);
if ( command.equals("OPEN")) {
if ( cli.qualifierFound("cli_arg1")) {
String jgraph = "JGRAPH";
String graph = "GRAPH";
String url = "URL";
String trend = "TREND";
String fast = "FAST";
String cli_arg1 = cli.getQualValue("cli_arg1").toUpperCase();
if ( jgraph.length() >= cli_arg1.length() &&
jgraph.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "OPEN JGRAPH"
System.out.println("Command is not implemented, \"OPEN JGRAPH\"");
}
else if ( graph.length() >= cli_arg1.length() &&
graph.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "OPEN GRAPH"
String graphName = null;
String instanceValue = null;
boolean classGraph = false;
if ( cli.qualifierFound("/INSTANCE")) {
instanceValue = cli.getQualValue("/INSTANCE");
classGraph = cli.qualifierFound("/CLASSGRAPH");
boolean parent = cli.qualifierFound("/PARENT");
if ( parent) {
int idx = instanceValue.lastIndexOf( '.');
if ( idx != -1 && idx != 0)
instanceValue = instanceValue.substring( 0, idx);
System.out.println( "open graph /parent: " + instanceValue);
}
}
if ( classGraph) {
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_CLASSGRAPH_NAME, instanceValue));
}
else {
if ( ! cli.qualifierFound("cli_arg2")) {
System.out.println("Syntax error");
return 0;
}
// Back to basic cmn
currentCmn = cmnList.get(0);
for ( int i = cmnList.size()-1; i > 0; i--)
cmnList.removeElementAt(i);
for ( int i = graphObject.size()-1; i >= 0; i--)
graphObject.removeElementAt(i);
graphName = cli.getQualValue("cli_arg2").toLowerCase();
if ( !graphName.contains(".pwg"))
graphName = graphName + ".pwg";
new ReaderTask().execute(new ReaderTaskArg(ReaderTask.GROW_READ, graphName, instanceValue));
}
}
else if ( url.length() >= cli_arg1.length() &&
url.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "OPEN URL"
Boolean newFrame = true;
String frameName = null;
String urlValue = cli.getQualValue("cli_arg2");
System.out.println("open url " + urlValue);
}
else if ( trend.length() >= cli_arg1.length() &&
trend.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "OPEN TREND"
}
else if ( fast.length() >= cli_arg1.length() &&
fast.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "OPEN FAST"
}
else if ( command.equals("HELP")) {
}
}
}
else if ( command.equals("SET")) {
if ( cli.qualifierFound("cli_arg1")) {
}
}
else if ( command.equals("CHECK")) {
if ( cli.qualifierFound("cli_arg1")) {
String methodstr = "METHOD";
String isattributestr = "ISATTRIBUTE";
String cli_arg1 = cli.getQualValue("cli_arg1").toUpperCase();
if ( methodstr.length() >= cli_arg1.length() &&
methodstr.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "CHECK METHOD"
String method;
String object;
if ( cli.qualifierFound("/METHOD"))
method = cli.getQualValue("/METHOD");
else {
System.out.println( "Cmd: Method is missing\n");
return 0;
}
if ( cli.qualifierFound("/OBJECT"))
object = cli.getQualValue("/OBJECT");
else {
System.out.println( "Cmd: Object is missing\n");
return 0;
}
}
else if ( isattributestr.length() >= cli_arg1.length() &&
isattributestr.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "CHECK ISATTRIBUTE"
String method;
String object;
if ( cli.qualifierFound("/OBJECT"))
object = cli.getQualValue("/OBJECT");
else {
System.out.println( "Cmd: Object is missing\n");
return 0;
}
}
}
else if ( command.equals("CALL")) {
if ( cli.qualifierFound("cli_arg1")) {
String parameter = "METHOD";
String cli_arg1 = cli.getQualValue("cli_arg1").toUpperCase();
if ( parameter.length() >= cli_arg1.length() &&
parameter.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "CHECK METHOD"
String method;
String object;
if ( cli.qualifierFound("/METHOD"))
method = cli.getQualValue("/METHOD");
else {
System.out.println( "Cmd: Method is missing\n");
return 0;
}
if ( cli.qualifierFound("/OBJECT"))
object = cli.getQualValue("/OBJECT");
else {
System.out.println( "Cmd: Object is missing\n");
return 0;
}
}
}
}
else if ( command.equals("SET")) {
return 1;
}
}
else {
System.out.println( "JopSpider: Parse error " + cli.getStsString());
return 0;
}
}
return 1;
}
public void invalidateView() {
view.invalidate();
}
// GdhApplIfc functions
@Override
public String getPwrHost() {
return pwrHost;
}
public PlowCmnIfc getCurrentCmn() {
return currentCmn;
}
}
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
dirs : $(app_package_dir)/$(comp_name)$(dir_ext)
$(app_package_dir)/$(comp_name)$(dir_ext) :
@ echo "Create directory " $(app_package_dir)/$(comp_name)$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_package_dir)/$(comp_name)$(dir_ext)
-include ../../special.mk
-include ../special.mk
-include special.mk
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/pwrxtt" />
</RelativeLayout>
\ No newline at end of file
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/close_option"
android:title="Close"
android:icon="@drawable/xnav_close"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/pageup_option"
android:title="Page up"
android:icon="@drawable/xnav_pageup"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/pagedown_option"
android:title="Page down"
android:icon="@drawable/xnav_pagedown"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/zoomin_option"
android:title="Zoom in"
android:icon="@drawable/xnav_zoomin"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/zoomout_option"
android:title="Zoom out"
android:icon="@drawable/xnav_zoomout"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/openobject_option"
android:title="Open Object"
android:icon="@drawable/xnav_openobject"/>
<item
android:id="@+id/openplc_option"
android:title="Open Plc"
android:icon="@drawable/xnav_openobject"/>
<item
android:id="@+id/opengraph_option"
android:title="Open Graph"
android:icon="@drawable/xnav_openobject"/>
<item
android:id="@+id/openclassgraph_option"
android:title="Open ObjectGraph"
android:icon="@drawable/xnav_openobject"/>
<item
android:id="@+id/opencrr_option"
android:title="Crossreferences"
android:icon="@drawable/xnav_openobject"/>
<item
android:id="@+id/alarmlist_option"
android:title="Alarm List"
android:icon="@drawable/xnav_openobject"/>
<item
android:id="@+id/eventlist_option"
android:title="Event List"
android:icon="@drawable/xnav_openobject"/>
<item
android:id="@+id/alarmack_option"
android:title="Alarm Acknowledge"
android:icon="@drawable/xnav_openobject"/>
<item
android:id="@+id/changevalue_option"
android:title="Change Value"/>
</menu>
\ No newline at end of file
include $(pwre_dir_symbols)
extern_java_sources :=
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
#
# Copy Gdh from rt_client
#
res_dirs_drawable := ../../../drawable
res_dirs_drawable_hdpi := ../../../drawable-hdpi
res_dirs_drawable_ldpi := ../../../drawable-ldpi
res_dirs_drawable_mdpi := ../../../drawable-mdpi
res_dirs_drawable_xhdpi := ../../../drawable-xhdpi
res_dirs_layout := ../../../layout
res_dirs_menu := ../../../menu
res_dirs_values := ../../../values
res_dirs_values_v11 := ../../../values-v11
res_dirs_values_v14 := ../../../values-v14
res_drawable_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(res_dirs_drawable), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
res_drawable_hdpi_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(res_dirs_drawable_hdpi), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
res_drawable_ldpi_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(res_dirs_drawable_ldpi), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
res_drawable_mdpi_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(res_dirs_drawable_mdpi), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
res_drawable_xhdpi_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(res_dirs_drawable_xhdpi), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
res_layout_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(res_dirs_layout), \
$(wildcard $(dir)/*.xml) \
), $(notdir $(file)) \
) \
)
res_menu_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(res_dirs_menu), \
$(wildcard $(dir)/*.xml) \
), $(notdir $(file)) \
) \
)
res_values_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(res_dirs_values), \
$(wildcard $(dir)/*.xml) \
), $(notdir $(file)) \
) \
)
res_values_v11_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(res_dirs_values_v11), \
$(wildcard $(dir)/*.xml) \
), $(notdir $(file)) \
) \
)
res_values_v14_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(res_dirs_values_v14), \
$(wildcard $(dir)/*.xml) \
), $(notdir $(file)) \
) \
)
res_drawable_objects := $(addprefix $(app_res_dir)/drawable/, $(res_drawable_sources))
res_drawable_hdpi_objects := $(addprefix $(app_res_dir)/drawable-hdpi/, $(res_drawable_hdpi_sources))
res_drawable_ldpi_objects := $(addprefix $(app_res_dir)/drawable-ldpi/, $(res_drawable_ldpi_sources))
res_drawable_mdpi_objects := $(addprefix $(app_res_dir)/drawable-mdpi/, $(res_drawable_mdpi_sources))
res_drawable_xhdpi_objects := $(addprefix $(app_res_dir)/drawable-xhdpi/, $(res_drawable_xhdpi_sources))
res_layout_objects := $(addprefix $(app_res_dir)/layout/, $(res_layout_sources))
res_menu_objects := $(addprefix $(app_res_dir)/menu/, $(res_menu_sources))
res_values_objects := $(addprefix $(app_res_dir)/values/, $(res_values_sources))
res_values_v11_objects := $(addprefix $(app_res_dir)/values-v11/, $(res_values_v11_sources))
res_values_v14_objects := $(addprefix $(app_res_dir)/values-v14/, $(res_values_v14_sources))
local_objects :=
dirs : $(app_res_dir)$(dir_ext) \
$(app_res_dir)/drawable$(dir_ext) \
$(app_res_dir)/drawable-hdpi$(dir_ext) \
$(app_res_dir)/drawable-ldpi$(dir_ext) \
$(app_res_dir)/drawable-mdpi$(dir_ext) \
$(app_res_dir)/drawable-xhdpi$(dir_ext) \
$(app_res_dir)/layout$(dir_ext) \
$(app_res_dir)/menu$(dir_ext) \
$(app_res_dir)/values$(dir_ext) \
$(app_res_dir)/values-v11$(dir_ext) \
$(app_res_dir)/values-v14$(dir_ext)
copy: $(res_drawable_objects) $(res_drawable_hdpi_objects) $(res_drawable_ldpi_objects) \
$(res_drawable_mdpi_objects) $(res_drawable_xhdpi_objects) $(res_layout_objects) \
$(res_menu_objects) $(res_values_objects) $(res_values_v11_objects) \
$(res_values_v14_objects)
$(app_res_dir)$(dir_ext) :
@ echo "Create directory " $(app_res_dir)$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)$(dir_ext)
$(app_res_dir)/drawable$(dir_ext) :
@ echo "Create directory " $(app_res_dir)/drawable$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)/drawable$(dir_ext)
$(app_res_dir)/drawable-hdpi$(dir_ext) :
@ echo "Create directory " $(app_res_dir)/drawable-hdpi$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)/drawable-hdpi$(dir_ext)
$(app_res_dir)/drawable-ldpi$(dir_ext) :
@ echo "Create directory " $(app_res_dir)/drawable-ldpi$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)/drawable-ldpi$(dir_ext)
$(app_res_dir)/drawable-mdpi$(dir_ext) :
@ echo "Create directory " $(app_res_dir)/drawable-mdpi$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)/drawable-mdpi$(dir_ext)
$(app_res_dir)/drawable-xhdpi$(dir_ext) :
@ echo "Create directory " $(app_res_dir)/drawable-xhdpi$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)/drawable-xhdpi$(dir_ext)
$(app_res_dir)/layout$(dir_ext) :
@ echo "Create directory " $(app_res_dir)/layout$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)/layout$(dir_ext)
$(app_res_dir)/menu$(dir_ext) :
@ echo "Create directory " $(app_res_dir)/menu$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)/menu$(dir_ext)
$(app_res_dir)/values$(dir_ext) :
@ echo "Create directory " $(app_res_dir)/values$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)/values$(dir_ext)
$(app_res_dir)/values-v11$(dir_ext) :
@ echo "Create directory " $(app_res_dir)/values-v11$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)/values-v11$(dir_ext)
$(app_res_dir)/values-v14$(dir_ext) :
@ echo "Create directory " $(app_res_dir)/values-v14$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_res_dir)/values-v14$(dir_ext)
$(app_res_dir)/drawable/%.png : ../../../../res/drawable/%.png
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(app_res_dir)/drawable-hdpi/%.png : ../../../../res/drawable-hdpi/%.png
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(app_res_dir)/drawable-ldpi/%.png : ../../../../res/drawable-ldpi/%.png
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(app_res_dir)/drawable-mdpi/%.png : ../../../../res/drawable-mdpi/%.png
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(app_res_dir)/drawable-xhdpi/%.png : ../../../../res/drawable-xhdpi/%.png
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(app_res_dir)/layout/%.xml : ../../../../res/layout/%.xml
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(app_res_dir)/menu/%.xml : ../../../../res/menu/%.xml
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(app_res_dir)/values/%.xml : ../../../../res/values/%.xml
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(app_res_dir)/values-v11/%.xml : ../../../../res/values-v11/%.xml
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(app_res_dir)/values-v14/%.xml : ../../../../res/values-v14/%.xml
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
-include ../../special.mk
-include ../special.mk
-include special.mk
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
\ No newline at end of file
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">PwrXtt</string>
<string name="pwrxtt">PwrXtt</string>
<string name="menu_settings">Settings</string>
</resources>
\ No newline at end of file
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
\ No newline at end of file
package jpwr.rt;
public class Mh {
public static final int mh_mEventFlags_Return = 0x01;
public static final int mh_mEventFlags_Ack = 0x02;
public static final int mh_mEventFlags_Bell = 0x04;
public static final int mh_mEventFlags_Force = 0x08;
public static final int mh_mEventFlags_InfoWindow = 0x10;
public static final int mh_mEventFlags_Returned = 0x20;
public static final int mh_mEventFlags_NoObject = 0x40;
public static final int mh_mEventStatus_NotRet = (1 << 0);
public static final int mh_mEventStatus_NotAck = (1 << 1);
public static final int mh_mEventStatus_Block = (1 << 2);
public static final int mh_eEventPrio__ = 0;
public static final int mh_eEventPrio_A = 67;
public static final int mh_eEventPrio_B = 66;
public static final int mh_eEventPrio_C = 65;
public static final int mh_eEventPrio_D = 64;
public static final int mh_eEventPrio_ = 63;
public static final int mh_eEvent__ = 0;
public static final int mh_eEvent_Ack = 1;
public static final int mh_eEvent_Block = 2;
public static final int mh_eEvent_Cancel = 3;
public static final int mh_eEvent_CancelBlock = 4;
public static final int mh_eEvent_Missing = 5;
public static final int mh_eEvent_Reblock = 6;
public static final int mh_eEvent_Return = 7;
public static final int mh_eEvent_Unblock = 8;
public static final int mh_eEvent_Info = 32;
public static final int mh_eEvent_Alarm = 64;
public static final int mh_eEvent_ = 65;
public static final int EventType_ClearAlarmList = 66;
}
include $(pwre_dir_symbols)
extern_java_sources := \
Cdh.java,\
CdhrAttrRef.java,\
CdhrBoolean.java,\
CdhrClassId.java,\
CdhrFloatArray.java,\
CdhrFloat.java,\
CdhrIntArray.java,\
CdhrInt.java,\
CdhrObjAttr.java,\
CdhrObjid.java,\
CdhrString.java,\
CdhrTypeId.java,\
CircBuffInfo.java,\
Cli.java,\
CliTable.java,\
GdhApplIfc.java,\
GdhrGetAttributeChar.java,\
GdhrGetXttObj.java,\
GdhrRefObjectInfo.java,\
MhData.java,\
MhrEvent.java,\
MhrsEventId.java,\
Pwrb.java,\
Pwr.java,\
Pwrs.java,\
PwrtAttrRef.java,\
PwrtObjid.java,\
PwrtRefId.java,\
PwrtStatus.java,\
Sub.java
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
#
# Copy Gdh from rt_client
#
local_objects := \
$(app_package_dir)/$(comp_name)/Gdh.java
copy: $(objects) $(local_objects)
dirs : $(app_package_dir)/$(comp_name)$(dir_ext)
$(app_package_dir)/$(comp_name)$(dir_ext) :
@ echo "Create directory " $(app_package_dir)/$(comp_name)$(dir_ext)
@ $(mkdir) -p $(mkdirflags) $(app_package_dir)/$(comp_name)$(dir_ext)
$(app_package_dir)/$(comp_name)/Gdh.java : $(pwre_sroot)/jpwr/rt_client/src/Gdh.java
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
-include ../../special.mk
-include ../special.mk
-include special.mk
...@@ -234,10 +234,11 @@ public class JopSessionRep implements JopSessionIfc { ...@@ -234,10 +234,11 @@ public class JopSessionRep implements JopSessionIfc {
if ( coid.objid.vid < Cdh.cUserClassVolMin || if ( coid.objid.vid < Cdh.cUserClassVolMin ||
(coid.objid.vid >= Cdh.cManufactClassVolMin && (coid.objid.vid >= Cdh.cManufactClassVolMin &&
coid.objid.vid <= Cdh.cManufactClassVolMax)) { coid.objid.vid <= Cdh.cManufactClassVolMax)) {
name = "$pwr_exe/" + name; if ( isApplication())
name = "$pwr_exe/" + name;
} }
if ( suffix.length() > 0) if ( suffix.length() > 0)
name = name.substring(0, pwgidx) + suffix + name.substring(pwgidx+1); name = name.substring(0, pwgidx) + suffix + name.substring(pwgidx);
} }
JopLog.log("openGraphFrame classgraph " + name); JopLog.log("openGraphFrame classgraph " + name);
......
...@@ -116,7 +116,8 @@ System.out.println( "qcom put finished"); ...@@ -116,7 +116,8 @@ System.out.println( "qcom put finished");
static CliTable[] cliTable = new CliTable[] { static CliTable[] cliTable = new CliTable[] {
new CliTable( "OPEN", new String[] {"cli_arg1", "cli_arg2", "/NAME", new CliTable( "OPEN", new String[] {"cli_arg1", "cli_arg2", "/NAME",
"/FILE", "/SCROLLBAR", "/WIDTH", "/HEIGHT", "/MENU", "/NAVIGATOR", "/FILE", "/SCROLLBAR", "/WIDTH", "/HEIGHT", "/MENU", "/NAVIGATOR",
"/CENTER", "/OBJECT", "/INSTANCE", "/NEW", "/CLASSGRAPH", "/ACCESS", "/PARENT"}), "/CENTER", "/OBJECT", "/INSTANCE", "/NEW", "/CLASSGRAPH", "/ACCESS", "/PARENT",
"/ACCESS"}),
new CliTable( "EXIT", null), new CliTable( "EXIT", null),
new CliTable( "HELP", new String[] {"cli_arg1", "cli_arg2", "cli_arg3", new CliTable( "HELP", new String[] {"cli_arg1", "cli_arg2", "cli_arg3",
"cli_arg4", "/HELPFILE", "/POPNAVIGATOR", "/BOOKMARK", "/INDEX", "cli_arg4", "/HELPFILE", "/POPNAVIGATOR", "/BOOKMARK", "/INDEX",
...@@ -222,8 +223,10 @@ System.out.println( "qcom put finished"); ...@@ -222,8 +223,10 @@ System.out.println( "qcom put finished");
return 0; return 0;
} }
int idx = cdhr.str.lastIndexOf( ".pwg"); int idx = cdhr.str.lastIndexOf( ".pwg");
if ( idx != -1) if ( idx != -1) {
appletName = cdhr.str.substring(0, idx); // appletName = cdhr.str.substring(0, idx);
appletName = cdhr.str; // atest
}
else { else {
idx = cdhr.str.lastIndexOf( ".class"); idx = cdhr.str.lastIndexOf( ".class");
if ( idx != -1) if ( idx != -1)
...@@ -240,8 +243,8 @@ System.out.println( "qcom put finished"); ...@@ -240,8 +243,8 @@ System.out.println( "qcom put finished");
instance = cdhr.str; instance = cdhr.str;
if ( session.isOpWindowApplet()) { if ( session.isOpWindowApplet()) {
appletName = appletName.substring(0,1).toUpperCase() + // atest appletName = appletName.substring(0,1).toUpperCase() +
appletName.substring(1); // appletName.substring(1);
System.out.println( "Open frame " + appletName); System.out.println( "Open frame " + appletName);
session.openGraphFrame( appletName, instance, false, false); session.openGraphFrame( appletName, instance, false, false);
} }
...@@ -342,6 +345,53 @@ System.out.println( "qcom put finished"); ...@@ -342,6 +345,53 @@ System.out.println( "qcom put finished");
System.out.println( "open graph /parent: " + instanceValue); System.out.println( "open graph /parent: " + instanceValue);
} }
} }
if ( cli.qualifierFound("/OBJECT")) {
String objectValue = cli.getQualValue("/OBJECT");
String objectName;
String appletName;
String instance = null;
// Replace * by node object
if ( objectValue.charAt(0) == '*') {
CdhrObjid cdhr_node = gdh.getNodeObject(0);
if ( cdhr_node.evenSts())
return 0;
CdhrString cdhr_nodestr = gdh.objidToName( cdhr_node.objid, Cdh.mName_volumeStrict);
objectName = cdhr_nodestr.str + objectValue.substring(1);
}
else
objectName = objectValue;
String attrName = objectName + ".Action";
CdhrString cdhr = gdh.getObjectInfoString( attrName);
if ( cdhr.evenSts()) {
System.out.println("Object name error");
return 0;
}
int idx = cdhr.str.lastIndexOf( ".pwg");
if ( idx != -1) {
// appletName = cdhr.str.substring(0, idx);
appletName = cdhr.str; // atest
}
else {
idx = cdhr.str.lastIndexOf( ".class");
if ( idx != -1)
appletName = cdhr.str.substring(0, idx);
else {
// This is a command
return command( session, cdhr.str);
}
}
attrName = objectName + ".Object";
cdhr = gdh.getObjectInfoString( attrName);
if ( cdhr.oddSts() && !cdhr.str.equals(""))
instance = cdhr.str;
System.out.println( "Open frame " + appletName);
session.openGraphFrame( appletName, instance, false, false);
local_cmd = true;
}
if ( !classGraph) { if ( !classGraph) {
if ( cli.qualifierFound("/FILE")) { if ( cli.qualifierFound("/FILE")) {
frameName = cli.getQualValue("/FILE"); frameName = cli.getQualValue("/FILE");
...@@ -785,7 +835,8 @@ System.out.println( "JopSpiderCmd start"); ...@@ -785,7 +835,8 @@ System.out.println( "JopSpiderCmd start");
String instance, boolean scrollbar) throws ClassNotFoundException { String instance, boolean scrollbar) throws ClassNotFoundException {
if ( className.indexOf(".pwg") != -1) { if ( className.indexOf(".pwg") != -1) {
GrowFrame frame = new GrowFrame(className, session.getGdh(), instance, new GrowFrameCb(session)); GrowFrame frame = new GrowFrame(className, session.getGdh(), instance, new GrowFrameCb(session),
session.getRoot());
frame.validate(); frame.validate();
frame.setVisible(true); frame.setVisible(true);
} }
......
...@@ -1024,7 +1024,7 @@ public class Dyn { ...@@ -1024,7 +1024,7 @@ public class Dyn {
return 0; return 0;
DynParsedAttrName pname = dyn.parseAttrName(attribute); DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname.name.equals("")) if ( pname == null || pname.name.equals(""))
return 1; return 1;
System.out.println("DigLowColor: " + attribute + " pname " + pname.name + " db " + pname.database); System.out.println("DigLowColor: " + attribute + " pname " + pname.name + " db " + pname.database);
...@@ -1078,7 +1078,7 @@ public class Dyn { ...@@ -1078,7 +1078,7 @@ public class Dyn {
else else
firstScan = false; firstScan = false;
if ( (dyn.dyn_type1 & Dyn.mDynType1_Tone) != 0) { if ( (dyn.total_dyn_type1 & Dyn.mDynType1_Tone) != 0) {
if ( !value) { if ( !value) {
if ( color >= Glow.eDrawTone__) if ( color >= Glow.eDrawTone__)
object.setFillColor( color); object.setFillColor( color);
...@@ -1220,7 +1220,7 @@ public class Dyn { ...@@ -1220,7 +1220,7 @@ public class Dyn {
else else
firstScan = false; firstScan = false;
if ( (dyn.dyn_type1 & Dyn.mDynType1_Tone) != 0) { if ( (dyn.total_dyn_type1 & Dyn.mDynType1_Tone) != 0) {
if ( value) { if ( value) {
if ( color >= Glow.eDrawTone__) { if ( color >= Glow.eDrawTone__) {
if ( dyn.resetColor) if ( dyn.resetColor)
...@@ -1373,7 +1373,7 @@ public class Dyn { ...@@ -1373,7 +1373,7 @@ public class Dyn {
else else
firstScan = false; firstScan = false;
if ( (dyn.dyn_type1 & Dyn.mDynType1_Tone) != 0) { if ( (dyn.total_dyn_type1 & Dyn.mDynType1_Tone) != 0) {
if ( value) { if ( value) {
object.setColorTone( Glow.eDrawTone_Yellow); object.setColorTone( Glow.eDrawTone_Yellow);
dyn.ignoreColor = true; dyn.ignoreColor = true;
...@@ -1509,7 +1509,7 @@ public class Dyn { ...@@ -1509,7 +1509,7 @@ public class Dyn {
else else
firstScan = false; firstScan = false;
if ( (dyn.dyn_type1 & Dyn.mDynType1_Tone) != 0) { if ( (dyn.total_dyn_type1 & Dyn.mDynType1_Tone) != 0) {
if ( value) { if ( value) {
object.setColorTone( Glow.eDrawTone_Red); object.setColorTone( Glow.eDrawTone_Red);
dyn.ignoreColor = true; dyn.ignoreColor = true;
...@@ -1647,7 +1647,7 @@ public class Dyn { ...@@ -1647,7 +1647,7 @@ public class Dyn {
else else
firstScan = false; firstScan = false;
if ( (dyn.dyn_type1 & Dyn.mDynType1_Tone) != 0) { if ( (dyn.total_dyn_type1 & Dyn.mDynType1_Tone) != 0) {
if ( value) { if ( value) {
if ( on) { if ( on) {
if ( color >= Glow.eDrawTone__) if ( color >= Glow.eDrawTone__)
...@@ -2049,6 +2049,9 @@ public class Dyn { ...@@ -2049,6 +2049,9 @@ public class Dyn {
public int connect(GlowArrayElem o) { public int connect(GlowArrayElem o) {
GrowNode object = (GrowNode)o; GrowNode object = (GrowNode)o;
if ( low_text == null)
return 1;
DynParsedAttrName pname = dyn.parseAttrName(attribute); DynParsedAttrName pname = dyn.parseAttrName(attribute);
if ( pname == null || pname.name.equals("")) if ( pname == null || pname.name.equals(""))
return 1; return 1;
...@@ -2130,7 +2133,7 @@ public class Dyn { ...@@ -2130,7 +2133,7 @@ public class Dyn {
break; break;
case Dyn.eSave_DigText_low_text: case Dyn.eSave_DigText_low_text:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
low_text = token.nextToken(); low_text = line.substring(5);
break; break;
case Dyn.eSave_DigText_instance: case Dyn.eSave_DigText_instance:
instance = Integer.valueOf(token.nextToken()); instance = Integer.valueOf(token.nextToken());
...@@ -2646,7 +2649,7 @@ public class Dyn { ...@@ -2646,7 +2649,7 @@ public class Dyn {
if ( !set_color && !reset_color) if ( !set_color && !reset_color)
return; return;
if ( (dyn.dyn_type1 & Dyn.mDynType1_Tone) != 0) { if ( (dyn.total_dyn_type1 & Dyn.mDynType1_Tone) != 0) {
if ( set_color) { if ( set_color) {
if ( color < Glow.eDrawTone__) if ( color < Glow.eDrawTone__)
object.setColorTone( color); object.setColorTone( color);
...@@ -6187,7 +6190,7 @@ public class Dyn { ...@@ -6187,7 +6190,7 @@ public class Dyn {
break; break;
case Dyn.eSave_TipText_text: case Dyn.eSave_TipText_text:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
text = token.nextToken(); text = line.substring(5);
break; break;
case Dyn.eSave_End: case Dyn.eSave_End:
end_found = true; end_found = true;
...@@ -6217,6 +6220,9 @@ public class Dyn { ...@@ -6217,6 +6220,9 @@ public class Dyn {
} }
public int action( GlowArrayElem o, GlowEvent e) { public int action( GlowArrayElem o, GlowEvent e) {
if ( topic == null)
return 1;
GrowNode object = (GrowNode)o; GrowNode object = (GrowNode)o;
switch ( e.event) { switch ( e.event) {
case Glow.eEvent_MB1Down: case Glow.eEvent_MB1Down:
...@@ -6232,7 +6238,7 @@ public class Dyn { ...@@ -6232,7 +6238,7 @@ public class Dyn {
break; break;
String command; String command;
if ( !bookmark.equals("")) if ( bookmark != null && !bookmark.equals(""))
command = new String("help " + topic + " /bookmark=" + bookmark); command = new String("help " + topic + " /bookmark=" + bookmark);
else else
command = new String("help " + topic); command = new String("help " + topic);
...@@ -7877,47 +7883,47 @@ public class Dyn { ...@@ -7877,47 +7883,47 @@ public class Dyn {
break; break;
case Dyn.eSave_OptionMenu_items_text1: case Dyn.eSave_OptionMenu_items_text1:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[1] = token.nextToken(); items_text[1] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text2: case Dyn.eSave_OptionMenu_items_text2:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[2] = token.nextToken(); items_text[2] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text3: case Dyn.eSave_OptionMenu_items_text3:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[3] = token.nextToken(); items_text[3] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text4: case Dyn.eSave_OptionMenu_items_text4:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[4] = token.nextToken(); items_text[4] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text5: case Dyn.eSave_OptionMenu_items_text5:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[5] = token.nextToken(); items_text[5] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text6: case Dyn.eSave_OptionMenu_items_text6:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[6] = token.nextToken(); items_text[6] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text7: case Dyn.eSave_OptionMenu_items_text7:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[7] = token.nextToken(); items_text[7] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text8: case Dyn.eSave_OptionMenu_items_text8:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[8] = token.nextToken(); items_text[8] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text9: case Dyn.eSave_OptionMenu_items_text9:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[9] = token.nextToken(); items_text[9] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text10: case Dyn.eSave_OptionMenu_items_text10:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[10] = token.nextToken(); items_text[10] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text11: case Dyn.eSave_OptionMenu_items_text11:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[11] = token.nextToken(); items_text[11] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text12: case Dyn.eSave_OptionMenu_items_text12:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
...@@ -7925,79 +7931,79 @@ public class Dyn { ...@@ -7925,79 +7931,79 @@ public class Dyn {
break; break;
case Dyn.eSave_OptionMenu_items_text13: case Dyn.eSave_OptionMenu_items_text13:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[13] = token.nextToken(); items_text[13] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text14: case Dyn.eSave_OptionMenu_items_text14:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[14] = token.nextToken(); items_text[14] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text15: case Dyn.eSave_OptionMenu_items_text15:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[15] = token.nextToken(); items_text[15] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text16: case Dyn.eSave_OptionMenu_items_text16:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[16] = token.nextToken(); items_text[16] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text17: case Dyn.eSave_OptionMenu_items_text17:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[17] = token.nextToken(); items_text[17] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text18: case Dyn.eSave_OptionMenu_items_text18:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[18] = token.nextToken(); items_text[18] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text19: case Dyn.eSave_OptionMenu_items_text19:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[19] = token.nextToken(); items_text[19] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text20: case Dyn.eSave_OptionMenu_items_text20:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[20] = token.nextToken(); items_text[20] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text21: case Dyn.eSave_OptionMenu_items_text21:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[21] = token.nextToken(); items_text[21] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text22: case Dyn.eSave_OptionMenu_items_text22:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[22] = token.nextToken(); items_text[22] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text23: case Dyn.eSave_OptionMenu_items_text23:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[23] = token.nextToken(); items_text[23] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text24: case Dyn.eSave_OptionMenu_items_text24:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[24] = token.nextToken(); items_text[24] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text25: case Dyn.eSave_OptionMenu_items_text25:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[25] = token.nextToken(); items_text[25] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text26: case Dyn.eSave_OptionMenu_items_text26:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[26] = token.nextToken(); items_text[26] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text27: case Dyn.eSave_OptionMenu_items_text27:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[27] = token.nextToken(); items_text[27] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text28: case Dyn.eSave_OptionMenu_items_text28:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[28] = token.nextToken(); items_text[28] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text29: case Dyn.eSave_OptionMenu_items_text29:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[29] = token.nextToken(); items_text[29] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text30: case Dyn.eSave_OptionMenu_items_text30:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[30] = token.nextToken(); items_text[30] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_text31: case Dyn.eSave_OptionMenu_items_text31:
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
items_text[31] = token.nextToken(); items_text[31] = line.substring(5);
break; break;
case Dyn.eSave_OptionMenu_items_enum0: case Dyn.eSave_OptionMenu_items_enum0:
items_enum[0] = Integer.valueOf(token.nextToken()); items_enum[0] = Integer.valueOf(token.nextToken());
......
...@@ -69,7 +69,7 @@ public class GlowArrow extends GlowArrayElem { ...@@ -69,7 +69,7 @@ public class GlowArrow extends GlowArrayElem {
while( (line = reader.readLine()) != null) { while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line); token = new StringTokenizer(line);
int key = Integer.valueOf(token.nextToken()); int key = Integer.valueOf(token.nextToken());
if ( cmn.debug) System.out.println( "Glowrrow : " + line); if ( cmn.debug) System.out.println( "GlowArrow : " + line);
switch ( key) { switch ( key) {
......
...@@ -45,9 +45,10 @@ import javax.swing.border.*; ...@@ -45,9 +45,10 @@ import javax.swing.border.*;
import java.awt.event.*; import java.awt.event.*;
public class GlowDraw implements GlowDrawIfc { public class GlowDraw implements GlowDrawIfc {
public static final int DRAW_FONT_SIZE = 9;
Graphics2D g2; Graphics2D g2;
boolean nodraw = true; boolean nodraw = true;
Font fonts[] = new Font[9]; Font fonts[] = new Font[DRAW_FONT_SIZE * 2];
public void setNodraw(boolean nodraw) { public void setNodraw(boolean nodraw) {
...@@ -103,6 +104,16 @@ public class GlowDraw implements GlowDrawIfc { ...@@ -103,6 +104,16 @@ public class GlowDraw implements GlowDrawIfc {
g2.fill(r); g2.fill(r);
} }
public void gradient_fill_rectrounded(int x, int y, int width, int height, int amount, int gc_type, int f1, int f2, int gradient) {
if ( nodraw)
return;
RoundRectangle2D r = new RoundRectangle2D.Float((float)x, (float)y, (float)width, (float)height,
(float)amount, (float)amount);
setGradient( gradient, f1, f2, (float)x, (float)y, (float)width, (float)height);
g2.fill(r);
}
public void arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type, int idx, int highlight) { public void arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type, int idx, int highlight) {
if ( nodraw) if ( nodraw)
return; return;
...@@ -253,7 +264,7 @@ public class GlowDraw implements GlowDrawIfc { ...@@ -253,7 +264,7 @@ public class GlowDraw implements GlowDrawIfc {
Color c = getColor(color); Color c = getColor(color);
g2.setFont(getFont(font_idx, idx)); g2.setFont(getFont(font_idx, idx, gc_type));
g2.setPaint(c); g2.setPaint(c);
g2.drawString(text, x, y); g2.drawString(text, x, y);
} }
...@@ -440,16 +451,21 @@ public class GlowDraw implements GlowDrawIfc { ...@@ -440,16 +451,21 @@ public class GlowDraw implements GlowDrawIfc {
} }
} }
public GlowDimension getTextExtent( String text, int idx, int type) { public GlowDimension getTextExtent( String text, int idx, int type, int gc_type) {
FontMetrics metrics = g2.getFontMetrics( getFont( type, idx)); FontMetrics metrics = g2.getFontMetrics( getFont( type, idx, gc_type));
GlowDimension dim = new GlowDimension(); GlowDimension dim = new GlowDimension();
dim.height = metrics.getHeight(); dim.height = metrics.getHeight();
dim.width = metrics.stringWidth(text); dim.width = metrics.stringWidth(text);
return dim; return dim;
} }
public Font getFont( int type, int idx) { public Font getFont( int type, int idx, int gc_type) {
if ( fonts[idx] == null) { int fidx;
fidx = idx;
if ( gc_type == Glow.eDrawType_TextHelveticaBold)
fidx += DRAW_FONT_SIZE;
if ( fonts[fidx] == null) {
int text_size; int text_size;
switch ( idx) { switch ( idx) {
case 0: text_size = 8; break; case 0: text_size = 8; break;
...@@ -463,9 +479,12 @@ public class GlowDraw implements GlowDrawIfc { ...@@ -463,9 +479,12 @@ public class GlowDraw implements GlowDrawIfc {
default: text_size = 24; default: text_size = 24;
} }
text_size *= 0.8; text_size *= 0.8;
fonts[idx] = new Font("Helvetica", Font.PLAIN, text_size); if ( fidx < DRAW_FONT_SIZE)
fonts[fidx] = new Font("Helvetica", Font.PLAIN, text_size);
else
fonts[fidx] = new Font("Helvetica", Font.BOLD, text_size);
} }
return fonts[idx]; return fonts[fidx];
} }
public int set_clip_rectangle( int x1, int y1, int x2, int y2) { public int set_clip_rectangle( int x1, int y1, int x2, int y2) {
......
...@@ -44,6 +44,7 @@ public interface GlowDrawIfc { ...@@ -44,6 +44,7 @@ public interface GlowDrawIfc {
public void rect(int x, int y, int width, int height, int gc_type, int idx, int highlight); public void rect(int x, int y, int width, int height, int gc_type, int idx, int highlight);
public void fill_rect(int x, int y, int width, int height, int gc_type); public void fill_rect(int x, int y, int width, int height, int gc_type);
public void gradient_fill_rect(int x, int y, int width, int height, int gc_type, int f1, int f2, int gradient); public void gradient_fill_rect(int x, int y, int width, int height, int gc_type, int f1, int f2, int gradient);
public void gradient_fill_rectrounded(int x, int y, int width, int height, int amount, int gc_type, int f1, int f2, int gradient);
public void arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type, int idx, int highlight); public void arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type, int idx, int highlight);
public void fill_arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type); public void fill_arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type);
public void gradient_fill_arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type, int f1, int f2, int gradient); public void gradient_fill_arc(int x, int y, int width, int height, int angle1, int angle2, int gc_type, int f1, int f2, int gradient);
...@@ -55,7 +56,7 @@ public interface GlowDrawIfc { ...@@ -55,7 +56,7 @@ public interface GlowDrawIfc {
public void text( int x, int y, String text, int gc_type, int color, int idx, int highlight, int line, 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); int font_idx, double size, int rot);
public int gradient_rotate(double rotate, int gradient); public int gradient_rotate(double rotate, int gradient);
public GlowDimension getTextExtent( String text, int idx, int type); public GlowDimension getTextExtent( String text, int idx, int type, int gc_type);
public Color getColor(int gc_type); public Color getColor(int gc_type);
public int set_clip_rectangle( int x1, int y1, int x2, int y2); public int set_clip_rectangle( int x1, int y1, int x2, int y2);
public void reset_clip_rectangle(); public void reset_clip_rectangle();
......
...@@ -113,7 +113,7 @@ public class GlowLine extends GlowArrayElem { ...@@ -113,7 +113,7 @@ public class GlowLine extends GlowArrayElem {
p1_y = (int)(p1.y * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y; p1_y = (int)(p1.y * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
p2_x = (int)(p2.x * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x; p2_x = (int)(p2.x * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
p2_y = (int)(p2.y * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y; p2_y = (int)(p2.y * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
if ( p1_x == p2_x && p1_y == p2_y) if ( p1_x == p2_x && p1_y == p2_y)
return; return;
int idx = (int)( cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * line_width - 1); int idx = (int)( cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * line_width - 1);
......
...@@ -39,7 +39,7 @@ import jpwr.rt.*; ...@@ -39,7 +39,7 @@ import jpwr.rt.*;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
public class GlowPoint { public class GlowPoint extends GlowArrayElem {
public double x; public double x;
public double y; public double 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 GlowPointDX {
public double x;
public double y;
}
\ No newline at end of file
...@@ -261,8 +261,8 @@ public class GlowTransform { ...@@ -261,8 +261,8 @@ public class GlowTransform {
return tmp.y( x1, y1); return tmp.y( x1, y1);
} }
public GlowPoint reverse( double x, double y) { public GlowPointDX reverse( double x, double y) {
GlowPoint p = new GlowPoint(); GlowPointDX p = new GlowPointDX();
if ( a11 == 0 || ( a12 * a21 - a11 * a22) == 0) { if ( a11 == 0 || ( a12 * a21 - a11 * a22) == 0) {
if ( a11 == 0 && a22 == 0 && a12 != 0 && a21 != 0) { if ( a11 == 0 && a22 == 0 && a12 != 0 && a21 != 0) {
p.y = (x - a13) / a12; p.y = (x - a13) / a12;
......
...@@ -117,6 +117,12 @@ public class GlowVector { ...@@ -117,6 +117,12 @@ public class GlowVector {
a.add( c); a.add( c);
break; break;
} }
case Glow.eSave_GrowRectRounded: {
GrowRectRounded c = new GrowRectRounded( cmn);
c.open( reader);
a.add( c);
break;
}
case Glow.eSave_Line: { case Glow.eSave_Line: {
GlowLine c = new GlowLine( cmn); GlowLine c = new GlowLine( cmn);
c.open( reader); c.open( reader);
......
...@@ -167,7 +167,7 @@ public class GrowAnnot extends GlowArrayElem { ...@@ -167,7 +167,7 @@ public class GrowAnnot extends GlowArrayElem {
int color; int color;
int rot; int rot;
double trf_scale = trf.vertical_scale( t); double trf_scale = trf.vertical_scale( t);
int idx = (int)( trf_scale * cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * (text_size +4) - 4); int idx = (int)( trf_scale * cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * (text_size +4) - 3);
double tsize = trf_scale * cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * (8+2*text_size); double tsize = trf_scale * cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * (8+2*text_size);
if ( idx < 0) if ( idx < 0)
return; return;
...@@ -213,7 +213,8 @@ public class GrowAnnot extends GlowArrayElem { ...@@ -213,7 +213,8 @@ public class GrowAnnot extends GlowArrayElem {
( !(rot < 45 || rot >= 315)) || ( !(rot < 45 || rot >= 315)) ||
adjustment == Glow.eAdjustment_Right || adjustment == Glow.eAdjustment_Right ||
adjustment == Glow.eAdjustment_Center) { adjustment == Glow.eAdjustment_Center) {
GlowDimension d = cmn.gdraw.getTextExtent( ((GrowNode)node).annotv[number], idx, ldraw_type); GlowDimension d = cmn.gdraw.getTextExtent( ((GrowNode)node).annotv[number], idx,
lfont, ldraw_type);
width = d.width; width = d.width;
height = d.height; height = d.height;
descent = height/4; descent = height/4;
...@@ -297,7 +298,7 @@ public class GrowAnnot extends GlowArrayElem { ...@@ -297,7 +298,7 @@ public class GrowAnnot extends GlowArrayElem {
color = GlowColor.get_drawtype( color_drawtype, Glow.eDrawType_LineHighlight, color = GlowColor.get_drawtype( color_drawtype, Glow.eDrawType_LineHighlight,
highlight, colornode, 2, 0); highlight, colornode, 2, 0);
GlowDimension d = cmn.gdraw.getTextExtent( "", 0, idx, ldraw_type); GlowDimension d = cmn.gdraw.getTextExtent( "", 0, idx, lfont, ldraw_type);
z_width = d.width; z_width = d.width;
z_height = d.height; z_height = d.height;
x_descent = z_height/4; x_descent = z_height/4;
......
...@@ -240,7 +240,7 @@ public class GrowArc extends GlowArrayElem { ...@@ -240,7 +240,7 @@ public class GrowArc extends GlowArrayElem {
} }
public int eventHandler( GlowEvent event, double fx, double fy) { public int eventHandler( GlowEvent event, double fx, double fy) {
GlowPoint rp; GlowPointDX rp;
switch ( event.event) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
......
...@@ -207,7 +207,8 @@ public class GrowAxis extends GrowRect { ...@@ -207,7 +207,8 @@ public class GrowAxis extends GrowRect {
if ( i % valuequotient == 0) { if ( i % valuequotient == 0) {
text = format_text( format, max_value - i * increment); text = format_text( format, max_value - i * increment);
GlowDimension d = cmn.gdraw.getTextExtent( text, GlowDimension d = cmn.gdraw.getTextExtent( text,
Math.max( 0, text_idx), Glow.eFont_Helvetica); Math.max( 0, text_idx), Glow.eFont_Helvetica,
text_drawtype);
z_width = d.width; z_width = d.width;
z_height = d.height; z_height = d.height;
z_descent = z_height/4; z_descent = z_height/4;
...@@ -259,7 +260,7 @@ public class GrowAxis extends GrowRect { ...@@ -259,7 +260,7 @@ public class GrowAxis extends GrowRect {
// Calculate max value text height // Calculate max value text height
if ( draw_text) { if ( draw_text) {
GlowDimension d = cmn.gdraw.getTextExtent( "0", GlowDimension d = cmn.gdraw.getTextExtent( "0",
Math.max( 0, text_idx), Glow.eFont_Helvetica); Math.max( 0, text_idx), Glow.eFont_Helvetica, text_drawtype);
z_width = d.width; z_width = d.width;
z_height = d.height; z_height = d.height;
...@@ -284,7 +285,7 @@ public class GrowAxis extends GrowRect { ...@@ -284,7 +285,7 @@ public class GrowAxis extends GrowRect {
if ( draw_text && i % valuequotient == 0) { if ( draw_text && i % valuequotient == 0) {
text = format_text( format, max_value - i * increment); text = format_text( format, max_value - i * increment);
GlowDimension d = cmn.gdraw.getTextExtent( text, GlowDimension d = cmn.gdraw.getTextExtent( text,
Math.max( 0, text_idx), Glow.eFont_Helvetica); Math.max( 0, text_idx), Glow.eFont_Helvetica, text_drawtype);
z_width = d.width; z_width = d.width;
z_height = d.height; z_height = d.height;
z_descent = z_height/4; z_descent = z_height/4;
...@@ -314,7 +315,7 @@ public class GrowAxis extends GrowRect { ...@@ -314,7 +315,7 @@ public class GrowAxis extends GrowRect {
if ( i % valuequotient == 0) { if ( i % valuequotient == 0) {
text = format_text( format, max_value - i * increment); text = format_text( format, max_value - i * increment);
GlowDimension d = cmn.gdraw.getTextExtent( text, GlowDimension d = cmn.gdraw.getTextExtent( text,
Math.max( 0, text_idx), Glow.eFont_Helvetica); Math.max( 0, text_idx), Glow.eFont_Helvetica, text_drawtype);
z_width = d.width; z_width = d.width;
z_height = d.height; z_height = d.height;
z_descent = z_height/4; z_descent = z_height/4;
...@@ -365,7 +366,8 @@ public class GrowAxis extends GrowRect { ...@@ -365,7 +366,8 @@ public class GrowAxis extends GrowRect {
// Calculate max value text height // Calculate max value text height
if ( draw_text) { if ( draw_text) {
GlowDimension d = cmn.gdraw.getTextExtent( "0", GlowDimension d = cmn.gdraw.getTextExtent( "0",
Math.max( 0, text_idx), Glow.eFont_Helvetica); Math.max( 0, text_idx), Glow.eFont_Helvetica,
text_drawtype);
z_width = d.width; z_width = d.width;
z_height = d.height; z_height = d.height;
...@@ -389,7 +391,7 @@ public class GrowAxis extends GrowRect { ...@@ -389,7 +391,7 @@ public class GrowAxis extends GrowRect {
if ( draw_text && i % valuequotient == 0) { if ( draw_text && i % valuequotient == 0) {
text = format_text( format, max_value - i * increment); text = format_text( format, max_value - i * increment);
GlowDimension d = cmn.gdraw.getTextExtent( text, GlowDimension d = cmn.gdraw.getTextExtent( text,
Math.max( 0, text_idx), Glow.eFont_Helvetica); Math.max( 0, text_idx), Glow.eFont_Helvetica, text_drawtype);
z_width = d.width; z_width = d.width;
z_height = d.height; z_height = d.height;
z_descent = z_height/4; z_descent = z_height/4;
......
...@@ -67,6 +67,8 @@ public class GrowCtx implements GrowCtxIfc { ...@@ -67,6 +67,8 @@ public class GrowCtx implements GrowCtxIfc {
while( (line = reader.readLine()) != null) { while( (line = reader.readLine()) != null) {
if ( line.length() > 2 && line.substring(0,2).equals("0!")) if ( line.length() > 2 && line.substring(0,2).equals("0!"))
continue; continue;
if ( line.length() > 1 && line.substring(0,1).equals("!"))
continue;
token = new StringTokenizer(line); token = new StringTokenizer(line);
int key = Integer.valueOf(token.nextToken()); int key = Integer.valueOf(token.nextToken());
......
...@@ -66,8 +66,8 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener { ...@@ -66,8 +66,8 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
String instance; String instance;
GrowFrameApplIfc appl; GrowFrameApplIfc appl;
public GrowFrame( String file, Gdh gdh, String instance, GrowFrameApplIfc appl) { public GrowFrame( String file, Gdh gdh, String instance, GrowFrameApplIfc appl, Object root) {
root = (Object) this; this.root = root;
this.instance = instance; this.instance = instance;
this.appl = appl; this.appl = appl;
init( file, gdh); init( file, gdh);
...@@ -89,6 +89,7 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener { ...@@ -89,6 +89,7 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
BufferedReader reader = null; BufferedReader reader = null;
String fname = file; String fname = file;
System.out.println("GrowFrame root: " + root);
if ( root != null && root instanceof JApplet) { if ( root != null && root instanceof JApplet) {
try { try {
URL current = ((JApplet) root).getCodeBase(); URL current = ((JApplet) root).getCodeBase();
...@@ -106,6 +107,31 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener { ...@@ -106,6 +107,31 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
// in = new BufferedInputStream(in); // in = new BufferedInputStream(in);
InputStreamReader r2 = new InputStreamReader(in); InputStreamReader r2 = new InputStreamReader(in);
reader = new BufferedReader( r2); reader = new BufferedReader( r2);
// 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);
}
} }
catch ( Exception e) { catch ( Exception e) {
System.out.println( "Unable to open file"); System.out.println( "Unable to open file");
...@@ -253,6 +279,7 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener { ...@@ -253,6 +279,7 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
} }
public void closeGrow() { public void closeGrow() {
timer.stop();
} }
// Exit when window is closed // Exit when window is closed
......
...@@ -180,7 +180,7 @@ public class GrowLine extends GlowArrayElem { ...@@ -180,7 +180,7 @@ public class GrowLine extends GlowArrayElem {
public int eventHandler( GlowEvent event, double fx, double fy) { public int eventHandler( GlowEvent event, double fx, double fy) {
/* /*
GlowPoint rp; GlowPointDX rp;
switch ( event.event) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
......
...@@ -110,7 +110,7 @@ public class GrowMenu extends GrowRect { ...@@ -110,7 +110,7 @@ public class GrowMenu extends GrowRect {
item_cnt = 0; item_cnt = 0;
for ( i = 0; i < info.item.length; i++) { for ( i = 0; i < info.item.length; i++) {
if ( info.item[i].occupied) { if ( info.item[i].occupied) {
GlowDimension dim = cmn.gdraw.getTextExtent( info.item[i].text, Math.max( 0, text_idx), font); GlowDimension dim = cmn.gdraw.getTextExtent( info.item[i].text, Math.max( 0, text_idx), font, text_drawtype);
z_width = dim.width; z_width = dim.width;
z_height = dim.height; z_height = dim.height;
z_descent = z_height/4; z_descent = z_height/4;
...@@ -249,7 +249,7 @@ public class GrowMenu extends GrowRect { ...@@ -249,7 +249,7 @@ public class GrowMenu extends GrowRect {
double rx, ry; double rx, ry;
// Convert koordinates to local koordinates // Convert koordinates to local koordinates
GlowPoint rp = trf.reverse( fx, fy); GlowPointDX rp = trf.reverse( fx, fy);
sts = 0; sts = 0;
switch ( event.event) { switch ( event.event) {
......
...@@ -346,7 +346,7 @@ public class GrowNode extends GlowArrayElem implements GlowColorNode { ...@@ -346,7 +346,7 @@ public class GrowNode extends GlowArrayElem implements GlowColorNode {
} }
public int eventHandler( GlowEvent event, double fx, double fy) { public int eventHandler( GlowEvent event, double fx, double fy) {
GlowPoint rp; GlowPointDX rp;
int sts; int sts;
switch ( event.event) { switch ( event.event) {
......
...@@ -286,7 +286,7 @@ public class GrowPolyline extends GlowArrayElem { ...@@ -286,7 +286,7 @@ public class GrowPolyline extends GlowArrayElem {
public int eventHandler( GlowEvent event, double fx, double fy) { public int eventHandler( GlowEvent event, double fx, double fy) {
/* /*
GlowPoint rp; GlowPointDX rp;
switch ( event.event) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
......
...@@ -266,7 +266,7 @@ public class GrowRect extends GlowArrayElem { ...@@ -266,7 +266,7 @@ public class GrowRect extends GlowArrayElem {
} }
public int eventHandler( GlowEvent event, double fx, double fy) { public int eventHandler( GlowEvent event, double fx, double fy) {
GlowPoint rp; GlowPointDX rp;
switch ( event.event) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
......
/*
* 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 GrowRectRounded extends GlowArrayElem {
GrowCmn cmn;
String n_name;
double x_right;
double x_left;
double y_high;
double y_low;
int original_border_drawtype;
int original_fill_drawtype;
int fill_drawtype;
int border;
double shadow_width;
int shadow_contrast;
int shadow;
int relief;
int disable_shadow;
int fixposition;
int gradient;
int gradient_contrast;
int disable_gradient;
int dynamicsize;
GlowTransform trf;
double round_amount;
GlowPoint ll;
GlowPoint ur;
int draw_type;
int line_width;
int display_level;
int fill;
public GrowRectRounded(GrowCmn cmn) {
this.cmn = cmn;
trf = new GlowTransform();
ll = new GlowPoint();
ur = new GlowPoint();
}
public int type() {
return Glow.eObjectType_GrowRectRounded;
}
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 = Integer.valueOf(token.nextToken());
if ( cmn.debug) System.out.println( "GrowRectRounded : " + line);
switch ( key) {
case Glow.eSave_GrowRectRounded:
break;
case Glow.eSave_GrowRectRounded_n_name:
if ( token.hasMoreTokens())
n_name = token.nextToken();
break;
case Glow.eSave_GrowRectRounded_x_right:
x_right = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowRectRounded_x_left:
x_left = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowRectRounded_y_high:
y_high = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowRectRounded_y_low:
y_low = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowRectRounded_original_border_drawtype:
original_border_drawtype = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_original_fill_drawtype:
original_fill_drawtype = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_fill_drawtype:
fill_drawtype = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_border:
border = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_round_amount:
round_amount = Double.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_shadow_width:
shadow_width = new Double(token.nextToken()).doubleValue();
break;
case Glow.eSave_GrowRectRounded_shadow_contrast:
shadow_contrast = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_shadow:
shadow = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_relief:
relief = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_disable_shadow:
disable_shadow = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_fixposition:
fixposition = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_gradient:
gradient = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_gradient_contrast:
gradient_contrast = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_disable_gradient:
disable_gradient = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_dynamicsize:
dynamicsize = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_GrowRectRounded_dynamic:
if ( cmn.dynamicsize > 0) {
for ( int j = 0; j < cmn.dynamicsize; j++)
line = reader.readLine(); // TODO handle backslash and citationmarks
}
break;
case Glow.eSave_GrowRectRounded_rect_part:
glowrect_open( reader);
break;
case Glow.eSave_GrowRectRounded_trf:
trf.open( reader);
break;
case Glow.eSave_End:
end_found = true;
break;
default:
System.out.println( "Syntax error in GrowRectRounded");
break;
}
if ( end_found)
break;
}
} catch ( Exception e) {
System.out.println( "IOException GrowRectRounded");
}
}
public void glowrect_open(BufferedReader reader) {
String line;
StringTokenizer token;
boolean end_found = false;
try {
while( (line = reader.readLine()) != null) {
token = new StringTokenizer(line);
int key = Integer.valueOf(token.nextToken());
if ( cmn.debug) System.out.println( "GlowRect : " + line);
switch ( key) {
case Glow.eSave_Rect:
break;
case Glow.eSave_Rect_draw_type:
draw_type = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_Rect_line_width:
line_width = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_Rect_display_level:
display_level = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_Rect_fill:
fill = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_Rect_ll:
ll.open( reader);
break;
case Glow.eSave_Rect_ur:
ur.open( reader);
break;
case Glow.eSave_End:
end_found = true;
break;
default:
System.out.println( "Syntax error in GlowRect");
break;
}
if ( end_found)
break;
}
} catch ( Exception e) {
System.out.println( "IOException GlowRect");
}
}
public int eventHandler( GlowEvent event, double fx, double fy) {
GlowPointDX rp;
switch ( event.event) {
case Glow.eEvent_CursorMotion:
return 0;
default: ;
}
rp = trf.reverse( fx, fy);
//rp = new GlowPoint();
//rp.x = fx;
//rp.y = fy;
if ( ll.x <= rp.x && rp.x <= ur.x &&
ll.y <= rp.y && rp.y <= ur.y) {
System.out.println( "Event handler: Hit in rect");
return 1;
}
else
return 0;
}
public void draw() {
draw( null, 0, 0, null, null);
}
public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {
if ( cmn.nodraw != 0)
return;
int chot = 0;
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 + 0.5) - cmn.mw.offset_x;
y1 = (int)( trf.y( ll.x, ll.y) * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
x2 = (int)( trf.x( ur.x, ur.y) * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
y2 = (int)( trf.y( ur.x, ur.y) * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
}
else {
x1 = (int)( trf.x( t, ll.x, ll.y) * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
y1 = (int)( trf.y( t, ll.x, ll.y) * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
x2 = (int)( trf.x( t, ur.x, ur.y) * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
y2 = (int)( trf.y( t, ur.x, ur.y) * cmn.mw.zoom_factor_y + 0.5) - 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);
int amount = (int)( round_amount/100 * Math.min(ur_x - ll_x, ur_y - ll_y) + 0.5);
if ( fill != 0) {
int ish = (int)( shadow_width / 100 * Math.min(ur_x - ll_x, ur_y - ll_y) + 0.5);
boolean display_shadow = ((node != null && ((GrowNode)node).shadow != 0) || shadow != 0) && disable_shadow == 0;
int fillcolor = GlowColor.get_drawtype( fill_drawtype, Glow.eDrawType_FillHighlight,
highlight, colornode, 1, 0);
int grad = gradient;
if ( gradient == Glow.eGradient_No &&
(node != null && ((GrowNode)node).gradient != Glow.eGradient_No) && disable_gradient == 0)
grad = ((GrowNode)node).gradient;
if ( !display_shadow && ish == 0) {
if ( grad == Glow.eGradient_No) {
if ( chot != 0)
drawtype = GlowColor.shift_drawtype( fillcolor, chot, 0);
else
drawtype = fillcolor;
cmn.gdraw.fill_rect( ll_x, ll_y + amount, ur_x - ll_x, ur_y - ll_y - 2*amount, drawtype);
cmn.gdraw.fill_rect( ll_x + amount, ll_y, ur_x - ll_x - 2*amount, amount, drawtype);
cmn.gdraw.fill_rect( ll_x + amount, ur_y - amount, ur_x - ll_x - 2*amount, amount, drawtype);
cmn.gdraw.fill_arc( ll_x, ll_y, 2*amount, 2*amount, 90, 90,
drawtype);
cmn.gdraw.fill_arc( ll_x, ur_y - 2*amount, 2*amount, 2*amount, 180, 90,
drawtype);
cmn.gdraw.fill_arc( ur_x - 2*amount, ur_y - 2*amount, 2*amount, 2*amount, 270, 90,
drawtype);
cmn.gdraw.fill_arc( ur_x - 2*amount, ll_y, 2*amount, 2*amount, 0, 90,
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( fillcolor, -gradient_contrast/2 + chot, 0);
f1 = GlowColor.shift_drawtype( fillcolor, (int)((float)(gradient_contrast)/2+0.6) + chot, 0);
}
else {
f2 = GlowColor.shift_drawtype( fillcolor, -(int)((float)(gradient_contrast)/2-0.6) + chot, 0);
f1 = GlowColor.shift_drawtype( fillcolor, gradient_contrast/2 + chot, 0);
}
cmn.gdraw.gradient_fill_rectrounded( ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, amount,
fillcolor, f1, f2, cmn.gdraw.gradient_rotate( rotation, grad));
}
}
else {
int drawtype_incr = shadow_contrast;
if ( relief == Glow.eRelief_Down)
drawtype_incr = -shadow_contrast;
// Draw light shadow
drawtype = GlowColor.shift_drawtype( fillcolor, -drawtype_incr + chot, colornode);
cmn.gdraw.fill_rect( ll_x + amount, ll_y, ur_x - ll_x - 2*amount, ish, drawtype);
cmn.gdraw.fill_rect( ll_x, ll_y + amount, ish, ur_y - ll_y - 2*amount, drawtype);
cmn.gdraw.fill_arc( ll_x, ll_y, 2*amount, 2*amount, 90, 90,
drawtype);
cmn.gdraw.fill_arc( ll_x, ur_y - 2*amount, 2*amount, 2*amount, 180, 45,
drawtype);
cmn.gdraw.fill_arc( ur_x - 2*amount, ll_y, 2*amount, 2*amount, 45, 45,
drawtype);
// Draw dark shadow
drawtype = GlowColor.shift_drawtype( fillcolor, drawtype_incr + chot, colornode);
cmn.gdraw.fill_rect( ll_x + amount, ur_y - ish, ur_x - ll_x - 2*amount, ish, drawtype);
cmn.gdraw.fill_rect( ur_x - ish, ll_y + amount, ish, ur_y - ll_y - 2*amount, drawtype);
cmn.gdraw.fill_arc( ll_x, ur_y - 2*amount, 2*amount, 2*amount, 225, 45,
drawtype);
cmn.gdraw.fill_arc( ur_x - 2*amount, ll_y, 2*amount, 2*amount, 0, 45,
drawtype);
cmn.gdraw.fill_arc( ur_x - 2*amount, ur_y - 2*amount, 2*amount, 2*amount, 270, 90,
drawtype);
if ( grad == Glow.eGradient_No) {
if ( chot != 0)
drawtype = GlowColor.shift_drawtype( fillcolor, chot, 0);
else
drawtype = fillcolor;
if ( amount > ish) {
cmn.gdraw.fill_rect( ll_x+ish, ll_y + amount, ur_x - ll_x-2*ish, ur_y - ll_y - 2*amount, drawtype);
cmn.gdraw.fill_rect( ll_x + amount, ll_y+ish, ur_x - ll_x - 2*amount, amount-ish, drawtype);
cmn.gdraw.fill_rect( ll_x + amount, ur_y - amount, ur_x - ll_x - 2*amount, amount-ish, drawtype);
cmn.gdraw.fill_arc( ll_x+ish, ll_y+ish, 2*amount-2*ish, 2*amount-2*ish, 90, 90,
drawtype);
cmn.gdraw.fill_arc( ll_x+ish, ur_y - 2*amount+ish, 2*amount-2*ish, 2*amount-2*ish, 180, 90,
drawtype);
cmn.gdraw.fill_arc( ur_x - 2*amount+ish, ur_y - 2*amount+ish, 2*amount-2*ish, 2*amount-2*ish, 270, 90,
drawtype);
cmn.gdraw.fill_arc( ur_x - 2*amount+ish, ll_y+ish, 2*amount-2*ish, 2*amount-2*ish, 0, 90,
drawtype);
}
else {
cmn.gdraw.fill_rect( ll_x+amount, ll_y + amount, ur_x - ll_x-2*amount, ur_y - ll_y - 2*amount, 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( fillcolor, -gradient_contrast/2 + chot, 0);
f1 = GlowColor.shift_drawtype( fillcolor, (int)((float)(gradient_contrast)/2+0.6) + chot, 0);
}
else {
f2 = GlowColor.shift_drawtype( fillcolor, -(int)((float)(gradient_contrast)/2-0.6) + chot, 0);
f1 = GlowColor.shift_drawtype( fillcolor, gradient_contrast/2 + chot, 0);
}
cmn.gdraw.gradient_fill_rectrounded( ll_x + ish, ll_y + ish, ur_x - ll_x - 2 * ish, ur_y - ll_y - 2 * ish,
amount - ish, fillcolor, f1, f2, cmn.gdraw.gradient_rotate( rotation, grad));
}
}
}
if ( border != 0 || fill == 0) {
drawtype = GlowColor.get_drawtype( draw_type, Glow.eDrawType_LineHighlight,
highlight, colornode, 0, 0);
int c = 0;
cmn.gdraw.line( ll_x + amount, ll_y, ur_x - amount, ll_y, drawtype, idx, 0);
cmn.gdraw.line( ll_x, ll_y-c + amount, ll_x, ur_y-c - amount, drawtype, idx, 0);
cmn.gdraw.line( ll_x + amount, ur_y, ur_x - amount, ur_y, drawtype, idx, 0);
cmn.gdraw.line( ur_x-c, ll_y + amount, ur_x-c, ur_y - amount, drawtype, idx, 0);
cmn.gdraw.arc( ll_x, ll_y, 2*amount, 2*amount, 90, 90,
drawtype, idx, 0);
cmn.gdraw.arc( ll_x, ur_y - 2*amount, 2*amount, 2*amount, 180, 90,
drawtype, idx, 0);
cmn.gdraw.arc( ur_x - 2*amount, ur_y - 2*amount, 2*amount, 2*amount, 270, 90,
drawtype, idx, 0);
cmn.gdraw.arc( ur_x - 2*amount, ll_y, 2*amount, 2*amount, 0, 90,
drawtype, idx, 0);
}
}
public void get_borders( GlowTransform t, GlowGeometry g) {
double ll_x, ur_x, ll_y, ur_y, x1, x2, y1, y2;
if ( t != null) {
x1 = trf.x( t, ll.x, ll.y);
x2 = trf.x( t, ur.x, ur.y);
y1 = trf.y( t, ll.x, ll.y);
y2 = trf.y( t, ur.x, ur.y);
}
else {
x1 = trf.x( ll.x, ll.y);
x2 = trf.x( ur.x, ur.y);
y1 = trf.y( ll.x, ll.y);
y2 = trf.y( ur.x, ur.y);
}
ll_x = Math.min( x1, x2);
ur_x = Math.max( x1, x2);
ll_y = Math.min( y1, y2);
ur_y = Math.max( y1, y2);
if ( ll_x < g.ll_x)
g.ll_x = ll_x;
if ( ur_x > g.ur_x)
g.ur_x = ur_x;
if ( ll_y < g.ll_y)
g.ll_y = ll_y;
if ( ur_y > g.ur_y)
g.ur_y = ur_y;
}
public void get_node_borders() {
GlowGeometry g = new GlowGeometry();
g.ll_x = g.ll_y = 1e37;
g.ur_x = g.ur_y = -1e37;
get_borders( null, g);
x_left = g.ll_x;
x_right = g.ur_x;
y_low = g.ll_y;
y_high = g.ur_y;
}
void set_scale( double scale_x, double scale_y,
double x0, double y0, int type) {
double old_x_left, old_x_right, old_y_low, old_y_high;
if ( trf.s_a11 != 0 && trf.s_a22 != 0 &&
Math.abs( scale_x - trf.a11 / trf.s_a11) < Float.MIN_VALUE &&
Math.abs( scale_y - trf.a22 / trf.s_a22) < Float.MIN_VALUE)
return;
switch( type) {
case Glow.eScaleType_LowerLeft:
x0 = x_left;
y0 = y_low;
break;
case Glow.eScaleType_LowerRight:
x0 = x_right;
y0 = y_low;
break;
case Glow.eScaleType_UpperRight:
x0 = x_right;
y0 = y_high;
break;
case Glow.eScaleType_UpperLeft:
x0 = x_left;
y0 = y_high;
break;
case Glow.eScaleType_FixPoint:
break;
case Glow.eScaleType_Center:
x0 = (x_left + x_right) / 2;
y0 = (y_low + y_high) /2;
break;
default:
;
}
old_x_left = x_left;
old_x_right = x_right;
old_y_low = y_low;
old_y_high = y_high;
trf.scale_from_stored( scale_x, scale_y, x0, y0);
get_node_borders();
switch( type) {
case Glow.eScaleType_LowerLeft:
x_left = old_x_left;
y_low = old_y_low;
break;
case Glow.eScaleType_LowerRight:
x_right = old_x_right;
y_low = old_y_low;
break;
case Glow.eScaleType_UpperRight:
x_right = old_x_right;
y_high = old_y_high;
break;
case Glow.eScaleType_UpperLeft:
x_left = old_x_left;
y_high = old_y_high;
break;
case Glow.eScaleType_FixPoint:
break;
case Glow.eScaleType_Center:
x0 = (x_left + x_right) / 2;
y0 = (y_low + y_high) /2;
break;
default:
;
}
cmn.ctx.draw( old_x_left * cmn.mw.zoom_factor_x - cmn.mw.offset_x - Glow.DRAW_MP,
old_y_low * cmn.mw.zoom_factor_y - cmn.mw.offset_y - Glow.DRAW_MP,
old_x_right * cmn.mw.zoom_factor_x - cmn.mw.offset_x + Glow.DRAW_MP,
old_y_high * cmn.mw.zoom_factor_y - cmn.mw.offset_y + Glow.DRAW_MP);
cmn.ctx.draw( x_left * cmn.mw.zoom_factor_x - cmn.mw.offset_x - Glow.DRAW_MP,
y_low * cmn.mw.zoom_factor_y - cmn.mw.offset_y - Glow.DRAW_MP,
x_right * cmn.mw.zoom_factor_x - cmn.mw.offset_x + Glow.DRAW_MP,
y_high * cmn.mw.zoom_factor_y - cmn.mw.offset_y + Glow.DRAW_MP);
}
}
\ No newline at end of file
...@@ -643,7 +643,7 @@ public class GrowTable extends GrowRect implements GrowScrollBarIfc { ...@@ -643,7 +643,7 @@ public class GrowTable extends GrowRect implements GrowScrollBarIfc {
column_adjustment[0] == Glow.eAdjustment_Center) { column_adjustment[0] == Glow.eAdjustment_Center) {
int width, height, descent; int width, height, descent;
GlowDimension dim = cmn.gdraw.getTextExtent( cell_value[offs], GlowDimension dim = cmn.gdraw.getTextExtent( cell_value[offs],
text_idx, font); text_idx, font, text_drawtype);
width = dim.width; width = dim.width;
height = dim.height; height = dim.height;
descent = height/4; descent = height/4;
...@@ -769,7 +769,7 @@ public class GrowTable extends GrowRect implements GrowScrollBarIfc { ...@@ -769,7 +769,7 @@ public class GrowTable extends GrowRect implements GrowScrollBarIfc {
column_adjustment[i] == Glow.eAdjustment_Center) { column_adjustment[i] == Glow.eAdjustment_Center) {
int width, height, descent; int width, height, descent;
GlowDimension dim = cmn.gdraw.getTextExtent( cell_value[offs], GlowDimension dim = cmn.gdraw.getTextExtent( cell_value[offs],
text_idx, font); text_idx, font, text_drawtype);
width = dim.width; width = dim.width;
height = dim.height; height = dim.height;
descent = height/4; descent = height/4;
......
...@@ -160,7 +160,7 @@ public class GrowText extends GlowArrayElem { ...@@ -160,7 +160,7 @@ public class GrowText extends GlowArrayElem {
color_drawtype = Integer.valueOf(token.nextToken()); color_drawtype = Integer.valueOf(token.nextToken());
break; break;
case Glow.eSave_Text_text: case Glow.eSave_Text_text:
text = token.nextToken(); text = line.substring(4);
break; break;
case Glow.eSave_Text_p: case Glow.eSave_Text_p:
p.open( reader); p.open( reader);
...@@ -169,7 +169,7 @@ public class GrowText extends GlowArrayElem { ...@@ -169,7 +169,7 @@ public class GrowText extends GlowArrayElem {
end_found = true; end_found = true;
break; break;
default: default:
System.out.println( "Syntax error in GlowText"); System.out.println( "Syntax error in GrowText");
break; break;
} }
if ( end_found) if ( end_found)
...@@ -184,7 +184,7 @@ public class GrowText extends GlowArrayElem { ...@@ -184,7 +184,7 @@ public class GrowText extends GlowArrayElem {
public int eventHandler( GlowEvent event, double fx, double fy) { public int eventHandler( GlowEvent event, double fx, double fy) {
/* /*
GlowPoint rp; GlowPointDX rp;
switch ( event.event) { switch ( event.event) {
case Glow.eEvent_CursorMotion: case Glow.eEvent_CursorMotion:
...@@ -217,7 +217,7 @@ public class GrowText extends GlowArrayElem { ...@@ -217,7 +217,7 @@ public class GrowText extends GlowArrayElem {
int z_width, z_height, z_descent; int z_width, z_height, z_descent;
int rot; int rot;
double trf_scale = trf.vertical_scale( t); double trf_scale = trf.vertical_scale( t);
int idx = (int)( trf_scale * cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * (text_size +4) - 4); int idx = (int)( trf_scale * cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * (text_size +4) - 3);
double tsize = trf_scale * cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * (8+2*text_size); double tsize = trf_scale * cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * (8+2*text_size);
idx = Math.min( idx, Glow.DRAW_TYPE_SIZE-1); idx = Math.min( idx, Glow.DRAW_TYPE_SIZE-1);
int highl = highlight; int highl = highlight;
...@@ -254,7 +254,7 @@ public class GrowText extends GlowArrayElem { ...@@ -254,7 +254,7 @@ public class GrowText extends GlowArrayElem {
if ( !text.equals("")) { if ( !text.equals("")) {
if ( highl != 0 || (hot != 0 && node == null) || adjustment != Glow.eAdjustment_Left) { if ( highl != 0 || (hot != 0 && node == null) || adjustment != Glow.eAdjustment_Left) {
GlowDimension dim = cmn.gdraw.getTextExtent( text, Math.max( 0, idx), lfont); GlowDimension dim = cmn.gdraw.getTextExtent( text, Math.max( 0, idx), lfont, ldraw_type);
z_width = dim.width; z_width = dim.width;
z_height = dim.height; z_height = dim.height;
z_descent = z_height/4; z_descent = z_height/4;
...@@ -308,7 +308,7 @@ public class GrowText extends GlowArrayElem { ...@@ -308,7 +308,7 @@ public class GrowText extends GlowArrayElem {
} }
} }
else if ( idx >= 0) { else if ( idx >= 0) {
GlowDimension dim = cmn.gdraw.getTextExtent( "A", Math.max( 0, idx), font); GlowDimension dim = cmn.gdraw.getTextExtent( "A", Math.max( 0, idx), lfont, ldraw_type);
z_width = dim.width; z_width = dim.width;
z_height = dim.height; z_height = dim.height;
z_descent = z_height/4; z_descent = z_height/4;
......
...@@ -7,14 +7,15 @@ local_java_sources := \ ...@@ -7,14 +7,15 @@ local_java_sources := \
GlowFillLevelLimits.java,\ GlowFillLevelLimits.java,\
GlowGeometry.java,\ GlowGeometry.java,\
GlowPointX.java,\ GlowPointX.java,\
GlowPointDX.java,\
GlowDimension.java,\ GlowDimension.java,\
GlowSliderInfo.java,\ GlowSliderInfo.java,\
GlowTableInfo.java,\ GlowTableInfo.java,\
GlowMenuInfo.java,\ GlowMenuInfo.java,\
GlowPoint.java,\
GlowTransform.java,\ GlowTransform.java,\
GlowEvent.java,\ GlowEvent.java,\
GlowArrayElem.java,\ GlowArrayElem.java,\
GlowPoint.java,\
GrowApplIfc.java,\ GrowApplIfc.java,\
GlowColorNode.java,\ GlowColorNode.java,\
GlowColorRgb.java,\ GlowColorRgb.java,\
...@@ -35,6 +36,7 @@ local_java_sources := \ ...@@ -35,6 +36,7 @@ local_java_sources := \
GlowArrow.java,\ GlowArrow.java,\
GlowCon.java,\ GlowCon.java,\
GrowRect.java,\ GrowRect.java,\
GrowRectRounded.java,\
GrowGroup.java,\ GrowGroup.java,\
GrowSlider.java,\ GrowSlider.java,\
GrowAxis.java,\ GrowAxis.java,\
......
...@@ -119,7 +119,7 @@ public class MhData ...@@ -119,7 +119,7 @@ public class MhData
this.addMessToVectorInSortedOrder(eventVec, ev.getCopy()); this.addMessToVectorInSortedOrder(eventVec, ev.getCopy());
break; break;
case Mh.mh_eEvent_Return: case Mh.mh_eEvent_Return:
//leta reda p objektet i larmlistan och vidta lmplig tgrd // Find the object in the alarm list
for(int i = 0; i < alarmVec.size(); i++) for(int i = 0; i < alarmVec.size(); i++)
{ {
MhrEvent alEv = (MhrEvent)alarmVec.get(i); MhrEvent alEv = (MhrEvent)alarmVec.get(i);
......
...@@ -197,6 +197,9 @@ public class Pwrb { ...@@ -197,6 +197,9 @@ public class Pwrb {
public static final int cClass_inv = 132168; public static final int cClass_inv = 132168;
public static final int cClass_IOHandler = 132176; public static final int cClass_IOHandler = 132176;
public static final int cClass_IpMux = 133192; public static final int cClass_IpMux = 133192;
public static final int cClass_Ii = 133664;
public static final int cClass_Io = 133672;
public static final int cClass_Iv = 133680;
public static final int cClass_IvArea = 133312; public static final int cClass_IvArea = 133312;
public static final int cClass_limit = 132192; public static final int cClass_limit = 132192;
public static final int cClass_Line_LAT = 132208; public static final int cClass_Line_LAT = 132208;
...@@ -287,6 +290,7 @@ public class Pwrb { ...@@ -287,6 +290,7 @@ public class Pwrb {
public static final int cClass_Store = 132896; public static final int cClass_Store = 132896;
public static final int cClass_StoreFormat = 132904; public static final int cClass_StoreFormat = 132904;
public static final int cClass_StoreTrig = 132912; public static final int cClass_StoreTrig = 132912;
public static final int cClass_Sv = 133496;
public static final int cClass_windowsubstep = 133128; public static final int cClass_windowsubstep = 133128;
public static final int cClass_substep = 132920; public static final int cClass_substep = 132920;
public static final int cClass_sum = 132944; public static final int cClass_sum = 132944;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
*/ */
/** /**
* Objekt som lagras i vektorn som sköter varje tråds, i GdhServer, prenumerationer * Object stored in supscription array for each thread in GdhServer
* *
*@author JN3920 *@author JN3920
*@created den 18 november 2002 *@created den 18 november 2002
......
...@@ -38,8 +38,6 @@ package jpwr.rt; ...@@ -38,8 +38,6 @@ package jpwr.rt;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import java.awt.*;
import javax.swing.*;
public class Gdh public class Gdh
{ {
...@@ -546,7 +544,7 @@ public class Gdh ...@@ -546,7 +544,7 @@ public class Gdh
{ {
while(locked) while(locked)
{ {
System.out.println("refObjectInfoList Vntar p locked = false"); System.out.println("refObjectInfoList Waiting for locked = false");
wait(); wait();
} }
} }
...@@ -607,7 +605,7 @@ public class Gdh ...@@ -607,7 +605,7 @@ public class Gdh
{ {
while(locked) while(locked)
{ {
System.out.println("refObjectInfo_Vector Vntar p locked = false"); System.out.println("refObjectInfo_Vector Waiting for locked = false");
wait(); wait();
} }
} }
...@@ -843,22 +841,22 @@ public class Gdh ...@@ -843,22 +841,22 @@ public class Gdh
{ {
while(locked) while(locked)
{ {
System.out.println("unrefObjectInfo Vntar p locked = false"); System.out.println("unrefObjectInfo Waiting for locked = false");
wait(); wait();
System.out.println("unrefObjectInfo Vntat klart"); System.out.println("unrefObjectInfo Wait done");
} }
} }
catch(InterruptedException e) catch(InterruptedException e)
{ {
System.out.println("Wait avbruten"); System.out.println("Wait interrupted");
} }
// if ( locked) // if ( locked)
// return new PwrtStatus(__BUSY); // return new PwrtStatus(__BUSY);
locked = true; locked = true;
if(refid.rix >= subscriptions.size()) if(refid.rix >= subscriptions.size())
{ {
//System.out.println("Frsker gra unrefObjectInfo med refid.rix= " + //System.out.println("unrefObjectInfo failed efid.rix " +
// refid.rix + " men sub.size= " + subscriptions.size() ); // refid.rix + " men sub.size= " + subscriptions.size() );
locked = false; locked = false;
notify(); notify();
...@@ -904,13 +902,13 @@ public class Gdh ...@@ -904,13 +902,13 @@ public class Gdh
{ {
while(locked) while(locked)
{ {
System.out.println("unrefobjectinfo_vector Vntar p locked = false"); System.out.println("unrefobjectinfo_vector Waiting for locked = false");
wait(); wait();
} }
} }
catch(InterruptedException e) catch(InterruptedException e)
{ {
System.out.println("Wait avbruten"); System.out.println("Wait interrupted");
} }
locked = true; locked = true;
try try
...@@ -970,13 +968,13 @@ public class Gdh ...@@ -970,13 +968,13 @@ public class Gdh
{ {
while(locked) while(locked)
{ {
System.out.println("unrefObjectInfoAll Vntar p locked = false"); System.out.println("unrefObjectInfoAll Waiting for locked = false");
wait(); wait();
} }
} }
catch(InterruptedException e) catch(InterruptedException e)
{ {
System.out.println("Wait avbruten"); System.out.println("Wait interrupted");
} }
locked = true; locked = true;
subscriptions.removeAllElements(); subscriptions.removeAllElements();
...@@ -1499,13 +1497,13 @@ public class Gdh ...@@ -1499,13 +1497,13 @@ public class Gdh
{ {
while(locked) while(locked)
{ {
System.out.println("getObjectRefInfoAll Vntar p locked = false"); System.out.println("getObjectRefInfoAll Waiting for locked = false");
wait(); wait();
} }
} }
catch(InterruptedException e) catch(InterruptedException e)
{ {
System.out.println("Wait avbruten"); System.out.println("Wait interrupted");
} }
try try
{ {
......
# lib_generic.mk -- generic makefile for libraries
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# To build a library.
#
ifndef aapp_generic_mk
aapp_generic_mk := 1
ifndef variables_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
appname := PwrXtt
packagename := jpwr
app_src_dir := $(release_root)/bld/$(type_name)/$(appname)/src
app_res_dir := $(release_root)/bld/$(type_name)/$(appname)/res
app_assets_dir := $(release_root)/bld/$(type_name)/$(appname)/assets
app_package_dir = $(app_src_dir)/$(packagename)
ifndef rules_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
vpath %.java $(hw_source):$(os_source):$(co_source):$(pwre_sroot)/jpwr/$(comp_name)/src
vpath %.gif $(hw_source):$(os_source):$(co_source)
vpath %.png $(hw_source):$(os_source):$(co_source)
#VPATH = $(hw_source):$(os_source):$(co_source)
source_dirs = $(hw_source) $(os_source) $(co_source)
png_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
java_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.java) \
), $(notdir $(file)) \
) \
)
jpwr_name := pwr_$(comp_name)
export_lib := $(lib_dir)/$(jpwr_name).jar
java_objects := $(addprefix $(app_package_dir)/$(comp_name)/, $(notdir $(addsuffix .java, $(basename $(extern_java_sources))))) $(addprefix $(app_package_dir)/$(comp_name)/, $(notdir $(addsuffix .java, $(basename $(java_sources)))))
png_objects := $(addprefix $(bld_dir)/, $(png_sources))
objects := $(png_objects) $(java_objects)
source_dependencies := $(notdir $(basename $(sources)))
source_dependencies := $(addprefix $(bld_dir)/, $(source_dependencies))
source_dependencies := $(addsuffix $(d_ext), $(source_dependencies))
.PHONY : all init copy lib exe clean realclean \
dirs clean_includes \
clean_bld clean_dirs clean_lib
# dirs $(clean_h_includes) $(clean_hpp_includes)
all : init copy lib exe
init : dirs
copy : $(objects) $(local_objects)
lib :
exe :
dirs :
#$(app_package_dir)/$(comp_name)$(dir_ext) $(app_res_dir)$(dir_ext)
clean : clean_bld
realclean : clean clean_dirs
clean_bld :
@ echo "Cleaning build directory"
@ $(rm) $(rmflags) $(bld_dir)/*
clean_dirs :
@ echo "Removing build directory"
@ $(rm) -r $(rmflags) $(bld_dir)
$(export_lib) : $(objects)
@ echo "Copy $(notdir $(bld_lib))"
#-include $(source_dependencies)
endif
...@@ -17,6 +17,7 @@ endif ...@@ -17,6 +17,7 @@ endif
.SUFFIXES: .SUFFIXES:
$(bld_dir)/%.cmsg $(inc_dir)/%.h: %.msg $(bld_dir)/%.cmsg $(inc_dir)/%.h: %.msg
@ $(log_msg_h) @ $(log_msg_h)
@ $(tools_msg2cmsg) $(source) $(bld_dir)/$(tname).cmsg $(inc_dir)/$(tname).h @ $(tools_msg2cmsg) $(source) $(bld_dir)/$(tname).cmsg $(inc_dir)/$(tname).h
...@@ -241,4 +242,13 @@ $(inc_dir)/%.meth : %.meth ...@@ -241,4 +242,13 @@ $(inc_dir)/%.meth : %.meth
@ $(log_h_h) @ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target) @ $(cp) $(cpflags) $(source) $(target)
# Rules for android apps
$(app_package_dir)/$(comp_name)/%.java : $(fco_source)/%.java
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(app_package_dir)/$(comp_name)/%.java : $(pwre_sroot)/jpwr/$(comp_name)/src/%.java
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
endif endif
...@@ -74,6 +74,29 @@ pwre_config_check_include() ...@@ -74,6 +74,29 @@ pwre_config_check_include()
echo "...Checking No $1" echo "...Checking No $1"
fi fi
} }
pwre_config_check_tool()
{
let i=0
let found=0
let incfound=0
IFS=:
for file in $3
do
if test -e $file; then
echo "...Checking Yes $1"
echo "export PWRE_CONF_$2=1" >> $cfile
found=1
break
fi
done
if test $found -eq 0; then
echo "...Checking No $1"
fi
}
# #
# Search for archive and insert in list # Search for archive and insert in list
# #
...@@ -411,7 +434,8 @@ else ...@@ -411,7 +434,8 @@ else
pwre_config_check_include mq MQ 0 "/usr/local/dmq/include/p_entry.h" pwre_config_check_include mq MQ 0 "/usr/local/dmq/include/p_entry.h"
pwre_config_check_include wmq WMQ 1 "/opt/mqm/inc/cmqc.h" pwre_config_check_include wmq WMQ 1 "/opt/mqm/inc/cmqc.h"
pwre_config_check_include cifx CIFX 1 "/usr/local/include/cifx/cifxlinux.h" pwre_config_check_include cifx CIFX 1 "/usr/local/include/cifx/cifxlinux.h"
pwre_config_check_include nodave NODAVE 1 "/usr/include/nodave.h" pwre_config_check_include nodave NODAVE 1 "/usr/include/nodave.h"
pwre_config_check_tool android ANDROID "/usr/local/android-sdk-linux/tools/android"
export pwre_conf_alsa=1 export pwre_conf_alsa=1
......
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