Commit ba53dd46 authored by Claes Sjofors's avatar Claes Sjofors

Java trace updated with triangles and more

parent 3b9b1b69
......@@ -82,6 +82,11 @@ public class Flow {
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 eDrawType_ = 10;
public static final int eDrawType_Green = 11;
public static final int eDrawType_Yellow = 12;
public static final int eDrawType_DarkGray = 13;
public static final int eDrawType_Inherit = 9999;
public static final int mDisplayLevel_1 = 1 << 0;
public static final int mDisplayLevel_2 = 1 << 2;
......@@ -117,6 +122,8 @@ public class Flow {
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_AnnotPixmapButton = 19;
public static final int eSave_Triangle = 20;
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;
......@@ -152,6 +159,7 @@ public class Flow {
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_Ctx_user_version = 134;
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;
......@@ -171,6 +179,7 @@ public class Flow {
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_Rect_fill = 505;
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;
......@@ -252,6 +261,7 @@ public class Flow {
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 final int eSave_Triangle_rect_part = 2000;
public static String getFileName(PwrtObjid oid) {
String filename = "pwr_" +
......
......@@ -106,7 +106,11 @@ public class FlowAnnot implements FlowArrayElem {
}
}
public void draw( FlowPoint p0, String[] annotv, boolean highlight) {
public void draw( FlowPoint p0, FlowNodeIfc node, boolean highlight) {
if ( node == null)
return;
String[] annotv = node.getAnnotv();
if ( annotv == null || annotv[number] == null)
return;
if ( (display_level & FlowCmn.display_level) == 0)
......
......@@ -107,7 +107,7 @@ public class FlowArc implements FlowArrayElem {
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
public void draw( FlowPoint p, FlowNodeIfc node, boolean highlight) {
int color;
switch ( draw_type) {
......
......@@ -72,6 +72,11 @@ public class FlowArray {
l.open( reader);
a.add( l);
break;
case Flow.eSave_Triangle:
FlowTriangle t = new FlowTriangle( cmn);
t.open( reader);
a.add( t);
break;
case Flow.eSave_Arc:
FlowArc arc = new FlowArc( cmn);
arc.open( reader);
......@@ -117,9 +122,9 @@ public class FlowArray {
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
public void draw( FlowPoint p, FlowNodeIfc node, boolean highlight) {
for ( int i = 0; i < a.size(); i++) {
((FlowArrayElem)a.get(i)).draw( p, annotv, highlight);
((FlowArrayElem)a.get(i)).draw( p, node, highlight);
}
}
......
......@@ -37,7 +37,7 @@
package jpwr.app;
public interface FlowArrayElem {
public void draw( FlowPoint p, String[] annotv, boolean highlight);
public void draw( FlowPoint p, FlowNodeIfc node, boolean highlight);
public boolean getSelect();
public void setSelect(boolean select);
public boolean eventHandler(PlowEvent e);
......
......@@ -113,7 +113,7 @@ public class FlowArrow implements FlowArrayElem {
System.out.println( "IOExeption FlowArrow");
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
public void draw( FlowPoint p, FlowNodeIfc node, boolean highlight) {
int color;
Path path = new Path();
......
......@@ -224,8 +224,8 @@ public class FlowCon implements FlowArrayElem {
}
public void setSelect( boolean select) {
}
public void draw( FlowPoint p0, String[] annotv, boolean highlight) {
// Adjust pos to javabean koordinates
public void draw( FlowPoint p0, FlowNodeIfc node, boolean highlight) {
// Adjust pos to javabean coordinates
FlowPoint p = new FlowPoint(cmn);
p.x = 0;
p.y = 0;
......
......@@ -102,7 +102,7 @@ public class FlowConPoint implements FlowArrayElem {
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
public void draw( FlowPoint p, FlowNodeIfc node, boolean highlight) {
}
@Override
public boolean getSelect() {
......
......@@ -117,6 +117,7 @@ public class FlowCtx implements FlowCtxInterface {
case Flow.eSave_Ctx_refcon_height:
case Flow.eSave_Ctx_refcon_textsize:
case Flow.eSave_Ctx_refcon_linewidth:
case Flow.eSave_Ctx_user_version:
break;
case Flow.eSave_Ctx_a_nc:
FlowVector.open( reader, cmn, cmn.a_nc);
......
......@@ -99,7 +99,7 @@ public class FlowLine implements FlowArrayElem {
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
public void draw( FlowPoint p, FlowNodeIfc node, boolean highlight) {
int color;
switch ( draw_type) {
......
......@@ -42,7 +42,7 @@ import java.io.*;
import java.util.*;
public class FlowNode implements FlowArrayElem {
public class FlowNode implements FlowArrayElem, FlowNodeIfc {
static final int OFFSET = 2;
double x_right;
double x_left;
......@@ -59,10 +59,12 @@ public class FlowNode implements FlowArrayElem {
int trace_attr_type;
boolean highlight;
boolean select;
int fill_color;
public FlowNode( FlowCmn cmn) {
this.cmn = cmn;
pos = new FlowPoint( cmn);
fill_color = Flow.eDrawType_Inherit;
}
@Override
......@@ -70,6 +72,12 @@ public class FlowNode implements FlowArrayElem {
return Flow.eObjectType_Node;
}
public String[] getAnnotv() {
return annotv;
}
public int getFillColor() {
return fill_color;
}
public boolean getSelect() {
return select;
}
......@@ -257,7 +265,7 @@ public class FlowNode implements FlowArrayElem {
*/
}
public void draw( FlowPoint p0, String[] annotv0, boolean hl) {
public void draw( FlowPoint p0, FlowNodeIfc node, boolean hl) {
if ( select) {
// Draw blue background
cmn.gdraw.rect(false, Plow.COLOR_LIGHTBLUE, (float)(x_left * cmn.zoom_factor - cmn.offset_x),
......@@ -266,7 +274,7 @@ public class FlowNode implements FlowArrayElem {
(float)(y_high * cmn.zoom_factor - cmn.offset_y));
}
nc.draw( pos, annotv, highlight);
nc.draw( pos, this, highlight);
}
......
......@@ -93,8 +93,8 @@ public class FlowNodeClass implements FlowArrayElem {
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
a.draw( p, annotv, highlight);
public void draw( FlowPoint p, FlowNodeIfc node, boolean highlight) {
a.draw( p, node, highlight);
}
@Override
public boolean getSelect() {
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2015 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 FlowNodeIfc {
public String[] getAnnotv();
public int getFillColor();
}
......@@ -45,6 +45,7 @@ public class FlowRect implements FlowArrayElem {
int draw_type;
int line_width;
int display_level;
int fill;
FlowCmn cmn;
public FlowRect( FlowCmn cmn) {
......@@ -79,6 +80,9 @@ public class FlowRect implements FlowArrayElem {
case Flow.eSave_Rect_display_level:
display_level = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Rect_fill:
fill = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Rect_ll:
ll.open( reader);
break;
......@@ -100,7 +104,7 @@ public class FlowRect implements FlowArrayElem {
}
}
public void draw( FlowPoint p, String[] annotv, boolean highlight) {
public void draw( FlowPoint p, FlowNodeIfc node, boolean highlight) {
if ( (display_level & FlowCmn.display_level) == 0)
return;
......
......@@ -97,7 +97,7 @@ public class FlowText implements FlowArrayElem {
}
}
public void draw( FlowPoint p0, String[] annotv, boolean highlight) {
public void draw( FlowPoint p0, FlowNodeIfc node, 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;
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2015 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.*;
/**
Flow triangle element.
*/
public class FlowTriangle extends FlowRect {
public FlowTriangle( FlowCmn cmn) {
super(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_Triangle_rect_part:
super.open(reader);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowTriangle");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowTriangle");
}
}
public void draw( FlowPoint p, FlowNodeIfc node, boolean highlight) {
int color;
if ( fill != 0) {
int dtype;
if ( node != null && node.getFillColor() != Flow.eDrawType_Inherit)
dtype = node.getFillColor();
else
dtype = draw_type;
switch ( dtype) {
case Flow.eDrawType_LineRed:
color = Plow.COLOR_RED;
break;
case Flow.eDrawType_Green:
color = Plow.COLOR_GREEN;
break;
case Flow.eDrawType_Yellow:
color = Plow.COLOR_YELLOW;
break;
default:
color = Plow.COLOR_GRAY;
}
cmn.gdraw.triangle(color, true,
(float)((ll.x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((ur.y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)(((ll.x + ur.x)/2 + 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));
}
color = Plow.COLOR_BLACK;
if ( highlight)
color = Plow.COLOR_RED;
cmn.gdraw.triangle(color, false,
(float)((ll.x + p.x) * cmn.zoom_factor - cmn.offset_x),
(float)((ur.y + p.y) * cmn.zoom_factor - cmn.offset_y),
(float)(((ll.x + ur.x)/2 + 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));
}
}
......@@ -162,6 +162,22 @@ public class PlowDraw implements PlowDrawIfc {
canvas.drawPath(path, paint);
}
public void triangle(int color, boolean fill, float x1, float y1, float x2, float y2, float x3, float y3) {
Path path = new Path();
paint.setColor(getColor(color));
if ( fill)
paint.setStyle(Paint.Style.FILL);
else
paint.setStyle(Paint.Style.STROKE);
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:
......
......@@ -10,6 +10,7 @@ public interface PlowDrawIfc {
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 void triangle(int color, boolean fill, float x1, float y1, float x2, float y2, float x3, float y3);
public int getCanvasWidth();
public int getCanvasHeight();
public void setCanvas(Canvas canvas);
......
......@@ -27,6 +27,7 @@ extern_java_sources := \
GlowPointX.java,\
GlowPointDX.java,\
GlowDimension.java,\
GlowDimensionD.java,\
GlowSliderInfo.java,\
GlowTableInfo.java,\
GlowMenuInfo.java,\
......@@ -43,8 +44,10 @@ extern_java_sources := \
GlowBackgroundObject.java,\
GlowEventMenu.java,\
GlowEventToolbar.java,\
GlowEventTable.java,\
GrowCtxIfc.java,\
GrowCmn.java,\
GrowAnnotIfc.java,\
GlowNodeClass.java,\
GlowNodeGroup.java,\
GlowConClass.java,\
......
......@@ -57,6 +57,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
String pwrp_load = "pwrp_load/";
String pwr_exe = "pwr_exe/";
Timer timer = new Timer();
MyTask timerTask;
MainView view;
Gdh gdh = null;
Handler handler = new Handler();
......@@ -126,7 +127,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
setContentView(view);
Log.i("PwrXtt", "Starting");
view.invalidate();
timer.schedule( new MyTask(), 0, 2000);
setScanTime(0.5);
DisplayMetrics metrics = getResources().getDisplayMetrics();
density = metrics.densityDpi / 150;
......@@ -160,6 +161,14 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
.setNegativeButton("Cancel", null)
.show();
}
void setScanTime( double time) {
if ( timerTask != null)
timerTask.cancel();
timerTask = new MyTask();
timer.schedule( timerTask, 0, (int)(1000 * time));
}
public void onClick(DialogInterface dialog, int position) {
if ( dialog == inputDialog) {
Editable value = editInput.getText();
......@@ -629,6 +638,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
cmnAla.setGDraw(gdraw);
PlowCmnEv cmnEve = new PlowCmnEv(appl, density * 15);
cmnEve.setGDraw(gdraw);
setScanTime( 1);
currentCmn = cmnAla;
aev = new AEv(cmnAla, cmnEve, appl);
cmnAla.setUserData(aev);
......@@ -636,6 +646,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
view.invalidate();
}
else {
setScanTime( 1);
currentCmn = aev.getCmnAla();
view.invalidate();
}
......@@ -653,6 +664,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
cmnAla.setGDraw(gdraw);
PlowCmnEv cmnEve = new PlowCmnEv(appl, density * 15);
cmnEve.setGDraw(gdraw);
setScanTime( 1);
currentCmn = cmnEve;
aev = new AEv(cmnAla, cmnEve, appl);
cmnAla.setUserData(aev);
......@@ -660,6 +672,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
view.invalidate();
}
else {
setScanTime( 1);
currentCmn = aev.getCmnEve();
view.invalidate();
}
......@@ -676,6 +689,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
view.invalidate();
}
else {
setScanTime( 1);
currentCmn = aev.getCmnEve();
view.invalidate();
}
......@@ -984,6 +998,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
PlowCmn cmn = new PlowCmn(appl, density * 15);
cmn.setGDraw(gdraw);
setScanTime( 1);
currentCmn = cmn;
cmnList.add(cmn);
AXtt axtt = new AXtt((PlowCmn)currentCmn, gdh);
......@@ -1055,6 +1070,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
PlowCmn cmn = new PlowCmn(appl, density * 15);
cmn.setGDraw(gdraw);
setScanTime( 1);
currentCmn = cmn;
cmnList.add(cmn);
AXtt axtt = new AXtt((PlowCmn)currentCmn, gdh);
......@@ -1505,6 +1521,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
}
if ( graphList.size() > 0) {
opwinCmn = new OpwinCmn(appl, graphList, density);
setScanTime( 1);
currentCmn = opwinCmn;
cmnList.add(opwinCmn);
}
......@@ -1925,14 +1942,14 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
if ( currentCmn.type() == PlowCmnIfc.TYPE_FLOW)
gdraw.setDensity(1, density);
else
gdraw.setDensity(density, density);
gdraw.setDensity(density * density, density);
currentCmn.setCanvas(currentCanvas);
currentCmn.draw();
/* Test
/* Test */
Paint paint = new Paint();
currentCanvas.drawText( "Density " + density, 10, 100, paint);
*/
/* */
getHolder().unlockCanvasAndPost(currentCanvas);
// currentCanvas = getHolder().lockCanvas();
......@@ -1996,6 +2013,7 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
return;
}
FlowCmn fcmn = new FlowCmn(this, gdh, windowObjid);
setScanTime( 1);
currentCmn = fcmn;
cmnList.add(fcmn);
fcmn.setGDraw(gdraw);
......@@ -2009,8 +2027,7 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
node.setSelect(true);
ctx.centerObject(node);
}
}
}
new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_OPEN, null));
}
......@@ -2052,6 +2069,7 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
graph.gdraw.setActivity(this);
GraphCmn cmn = new GraphCmn(graph);
currentCmn = cmn;
setScanTime( graph.getAnimationScanTime());
cmnList.add(cmn);
// new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_OPEN, null));
......@@ -2269,6 +2287,7 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
if ( opwinCmn != null)
cmnIdx = 1;
setScanTime( 1);
currentCmn = cmnList.get(cmnIdx);
for ( int i = cmnList.size()-1; i > cmnIdx; i--)
cmnList.removeElementAt(i);
......@@ -2493,6 +2512,7 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
}
public void closeGraph() {
setScanTime( 1);
new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_CLOSE, currentCmn));
if (graphObject.size() > 0)
graphObject.removeElementAt(graphObject.size()-1);
......@@ -2551,6 +2571,7 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
if ( cmnList.size() == 1) {
// Open opwin
if ( opwinCmn != null) {
setScanTime( 1);
currentCmn = opwinCmn;
cmnList.add(opwinCmn);
view.invalidate();
......@@ -2563,6 +2584,7 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
PlowNode o = (PlowNode)cmn.get(0);
AXttItemObject itemo = (AXttItemObject)o.getUserData();
itemo.close(axtt);
setScanTime( 1);
currentCmn = cmnList.get(cmnList.size()-2);
cmnList.removeElementAt(cmnList.size()-1);
System.out.println( "cmnList.size() " + cmnList.size());
......@@ -2572,6 +2594,7 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
case PlowCmnIfc.TYPE_FLOW:
new GdhTask().execute(new GdhTaskArg(GdhTask.DYNAMIC_CLOSE, currentCmn));
System.out.println( "cmnList.size() " + cmnList.size());
setScanTime( 1);
currentCmn = cmnList.get(cmnList.size()-2);
cmnList.removeElementAt(cmnList.size()-1);
System.out.println( "cmnList.size() " + cmnList.size());
......@@ -2580,6 +2603,7 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
break;
case PlowCmnIfc.TYPE_EV:
System.out.println( "cmnList.size() " + cmnList.size());
setScanTime( 1);
currentCmn = cmnList.get(cmnList.size()-1);
aev = null;
view.invalidate();
......@@ -2590,6 +2614,7 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
System.out.println( "cmnList.size() " + cmnList.size());
if (graphObject.size() > 0)
graphObject.removeElementAt(graphObject.size()-1);
setScanTime( 1);
currentCmn = cmnList.get(cmnList.size()-2);
cmnList.removeElementAt(cmnList.size()-1);
System.out.println( "cmnList.size() " + cmnList.size());
......
......@@ -67,6 +67,11 @@ public class Flow {
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 eDrawType_ = 10;
public static final int eDrawType_Green = 11;
public static final int eDrawType_Yellow = 12;
public static final int eDrawType_DarkGray = 13;
public static final int eDrawType_Inherit = 9999;
public static final int mDisplayLevel_1 = 1 << 0;
public static final int mDisplayLevel_2 = 1 << 2;
......@@ -102,6 +107,8 @@ public class Flow {
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_AnnotPixmapButton = 19;
public static final int eSave_Triangle = 20;
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;
......@@ -137,6 +144,7 @@ public class Flow {
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_Ctx_user_version = 134;
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;
......@@ -156,6 +164,7 @@ public class Flow {
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_Rect_fill = 505;
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;
......@@ -237,4 +246,5 @@ public class Flow {
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 final int eSave_Triangle_rect_part = 2000;
}
......@@ -108,7 +108,11 @@ public class FlowAnnot implements FlowArrayElem {
}
}
public void draw( Graphics2D g, FlowPoint p0, String[] annotv, boolean highlight) {
public void draw( Graphics2D g, FlowPoint p0, FlowNodeIfc node, boolean highlight) {
if ( node == null)
return;
String[] annotv = node.getAnnotv();
if ( annotv[number] == null)
return;
if ( (display_level & FlowCmn.display_level) == 0)
......
......@@ -108,7 +108,7 @@ public class FlowArc implements FlowArrayElem {
}
}
public void draw( Graphics2D g, FlowPoint p, String[] annotv, boolean highlight) {
public void draw( Graphics2D g, FlowPoint p, FlowNodeIfc node, boolean highlight) {
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,
......
......@@ -79,6 +79,11 @@ public class FlowArray {
l.open( reader);
a.add( l);
break;
case Flow.eSave_Triangle:
FlowTriangle t = new FlowTriangle( cmn);
t.open( reader);
a.add( t);
break;
case Flow.eSave_Arc:
FlowArc arc = new FlowArc( cmn);
arc.open( reader);
......@@ -124,9 +129,9 @@ public class FlowArray {
}
}
public void draw( Graphics2D g, FlowPoint p, String[] annotv, boolean highlight) {
public void draw( Graphics2D g, FlowPoint p, FlowNodeIfc node, boolean highlight) {
for ( int i = 0; i < a.size(); i++) {
((FlowArrayElem)a.get(i)).draw( g, p, annotv, highlight);
((FlowArrayElem)a.get(i)).draw( g, p, node, highlight);
}
}
......
......@@ -39,5 +39,5 @@ import java.awt.*;
import javax.swing.*;
public interface FlowArrayElem {
public void draw( Graphics2D g, FlowPoint p, String[] annotv, boolean highlight);
public void draw( Graphics2D g, FlowPoint p, FlowNodeIfc node, boolean highlight);
}
......@@ -113,7 +113,7 @@ public class FlowArrow implements FlowArrayElem {
System.out.println( "IOExeption FlowArrow");
}
}
public void draw( Graphics2D g, FlowPoint p, String[] annotv, boolean highlight) {
public void draw( Graphics2D g, FlowPoint p, FlowNodeIfc node, boolean highlight) {
Polygon pol = new Polygon( new int[] {
(int) ((p1.x + p.x) * cmn.zoom_factor),
(int) ((p2.x + p.x) * cmn.zoom_factor),
......
......@@ -71,7 +71,7 @@ public class FlowCmn {
this.ctx = ctx;
this.gdh = gdh;
this.session = session;
this.debug = false;
this.debug = true;
this.antiAliasing = true;
}
......
......@@ -104,7 +104,7 @@ public class FlowConPoint implements FlowArrayElem {
}
}
public void draw( Graphics2D g, FlowPoint p, String[] annotv, boolean highlight) {
public void draw( Graphics2D g, FlowPoint p, FlowNodeIfc node, boolean highlight) {
}
}
......
......@@ -118,6 +118,7 @@ public class FlowCtx implements FlowCtxInterface {
case Flow.eSave_Ctx_refcon_height:
case Flow.eSave_Ctx_refcon_textsize:
case Flow.eSave_Ctx_refcon_linewidth:
case Flow.eSave_Ctx_user_version:
break;
case Flow.eSave_Ctx_a_nc:
FlowVector.open( reader, cmn, cmn.a_nc);
......
......@@ -100,7 +100,7 @@ public class FlowLine implements FlowArrayElem {
}
}
public void draw( Graphics2D g, FlowPoint p, String[] annotv, boolean highlight) {
public void draw( Graphics2D g, FlowPoint p, FlowNodeIfc node, boolean highlight) {
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,
......
......@@ -51,7 +51,7 @@ import java.awt.event.*;
<p>
A flow node is a function object built by element of type arcs, lines, recangles, texts etc.
*/
public class FlowNode extends JComponent implements FlowComponent, JopDynamic {
public class FlowNode extends JComponent implements FlowComponent, FlowNodeIfc, JopDynamic {
static final int OFFSET = 2;
double x_right;
double x_left;
......@@ -70,16 +70,22 @@ public class FlowNode extends JComponent implements FlowComponent, JopDynamic {
boolean highlight;
boolean select;
Component component;
int fill_color;
public FlowNode( FlowCmn cmn) {
component = this;
this.cmn = cmn;
pos = new FlowPoint( cmn);
size = new Dimension(40,40); // .....todo
fill_color = Flow.eDrawType_Inherit;
}
public String[] getAnnotv() {
return annotv;
}
public int getFillColor() {
return fill_color;
}
public boolean getSelect() {
return select;
}
......@@ -282,7 +288,7 @@ public class FlowNode extends JComponent implements FlowComponent, JopDynamic {
FlowPoint p = new FlowPoint(cmn);
p.x = pos.x - x_left + ((double) Flow.DRAWOFFSET) / cmn.zoom_factor;
p.y = pos.y - y_low + ((double) Flow.DRAWOFFSET) / cmn.zoom_factor;
nc.draw( g, p, annotv, highlight);
nc.draw( g, p, this, highlight);
}
boolean attrFound;
......
......@@ -95,8 +95,8 @@ public class FlowNodeClass {
}
}
public void draw( Graphics2D g, FlowPoint p, String[] annotv, boolean highlight) {
a.draw( g, p, annotv, highlight);
public void draw( Graphics2D g, FlowPoint p, FlowNodeIfc node, boolean highlight) {
a.draw( g, p, node, highlight);
}
}
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2015 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.jop;
import java.awt.*;
import javax.swing.*;
public interface FlowNodeIfc {
public String[] getAnnotv();
public int getFillColor();
}
......@@ -51,6 +51,7 @@ public class FlowRect implements FlowArrayElem {
int draw_type;
int line_width;
int display_level;
int fill;
FlowCmn cmn;
public FlowRect( FlowCmn cmn) {
......@@ -80,6 +81,9 @@ public class FlowRect implements FlowArrayElem {
case Flow.eSave_Rect_display_level:
display_level = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Rect_fill:
fill = new Integer( token.nextToken()).intValue();
break;
case Flow.eSave_Rect_ll:
ll.open( reader);
break;
......@@ -101,7 +105,7 @@ public class FlowRect implements FlowArrayElem {
}
}
public void draw( Graphics2D g, FlowPoint p, String[] annotv, boolean highlight) {
public void draw( Graphics2D g, FlowPoint p, FlowNodeIfc node, boolean highlight) {
if ( (display_level & FlowCmn.display_level) == 0)
return;
......
......@@ -98,7 +98,7 @@ public class FlowText implements FlowArrayElem {
}
}
public void draw( Graphics2D g, FlowPoint p0, String[] annotv, boolean highlight) {
public void draw( Graphics2D g, FlowPoint p0, FlowNodeIfc node, boolean highlight) {
int tsize;
int idx = (int)(cmn.zoom_factor / cmn.base_zoom_factor * (text_size +4) - 4);
if ( idx < 0) return;
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2015 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.jop;
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
/**
Flow triangle element.
*/
public class FlowTriangle extends FlowRect {
public FlowTriangle( FlowCmn cmn) {
super(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_Triangle_rect_part:
super.open(reader);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println( "Syntax error in FlowTriangle");
break;
}
if ( end)
break;
}
} catch ( Exception e) {
System.out.println( "IOExeption FlowTriangle");
}
}
public void draw( Graphics2D g, FlowPoint p, FlowNodeIfc node, boolean highlight) {
if ( (display_level & FlowCmn.display_level) == 0)
return;
Polygon pol = new Polygon( new int[] {
(int) ((ll.x + p.x) * cmn.zoom_factor),
(int) (((ll.x + ur.x) / 2 + p.x) * cmn.zoom_factor),
(int) ((ur.x + p.x) * cmn.zoom_factor),
(int) ((ll.x + p.x) * cmn.zoom_factor)},
new int[] {
(int) ((ur.y + p.y) * cmn.zoom_factor),
(int) ((ll.y + p.y) * cmn.zoom_factor),
(int) ((ur.y + p.y) * cmn.zoom_factor),
(int) ((ur.y + p.y) * cmn.zoom_factor)},
4);
g.setStroke( new BasicStroke( (float)(cmn.zoom_factor / cmn.base_zoom_factor * line_width)));
if ( fill != 0) {
int dtype;
if ( node != null && node.getFillColor() != Flow.eDrawType_Inherit)
dtype = node.getFillColor();
else
dtype = draw_type;
switch ( dtype) {
case Flow.eDrawType_LineRed:
g.setColor( Color.red);
break;
case Flow.eDrawType_Green:
g.setColor( Color.green);
break;
case Flow.eDrawType_Yellow:
g.setColor( Color.yellow);
break;
default:
g.setColor( Color.gray);
}
g.fill( pol);
}
g.setColor( Color.black);
if ( highlight)
g.setColor( Color.red);
g.draw( pol);
}
}
......@@ -99,12 +99,14 @@ local_java_sources := \
GeFrameThin.java \
Flow.java \
FlowCtxInterface.java \
FlowNodeIfc.java \
FlowCmn.java \
FlowComponent.java \
FlowPoint.java \
FlowArrayElem.java \
FlowRect.java \
FlowLine.java \
FlowTriangle.java \
FlowText.java \
FlowArc.java \
FlowArrow.java \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment