Commit 5f9ff3c5 authored by Claes Sjofors's avatar Claes Sjofors

Java android app work

parent e01bb94c
......@@ -4,6 +4,7 @@ import android.graphics.Bitmap;
public class AGraphInfo {
public Bitmap bpm;
public Bitmap bpmInverted;
public String graph;
public String text;
public int iconX;
......@@ -12,4 +13,5 @@ public class AGraphInfo {
public int iconHeight;
public int textX;
public int textY;
public boolean inverted = false;
}
......@@ -11,6 +11,8 @@ public class AXttItemAttrObject extends AXttItemBase {
String name;
int flags;
int type;
PwrtAttrRef aref;
AXttItemAttrObject(AXtt axtt, PwrtObjid objid, String name, String fullName, int flags, int type,
PlowNode destination, int destCode) {
......@@ -20,9 +22,24 @@ public class AXttItemAttrObject extends AXttItemBase {
this.flags = flags;
this.type = type;
CdhrAttrRef ar = axtt.gdh.nameToAttrRef( fullName);
if ( ar.evenSts()) return;
aref = ar.aref;
CdhrTypeId cr = axtt.gdh.getAttrRefTid( ar.aref);
if ( cr.evenSts()) return;
CdhrObjid coidret = axtt.gdh.classIdToObjid(cr.typeId);
if ( coidret.evenSts()) return;
CdhrString cnameret = axtt.gdh.objidToName(coidret.objid, Cdh.mName_object);
if ( cnameret.evenSts()) return;
node = new PlowNode(axtt.cmn, 0, 0, axtt.ncObject);
node.setAnnotPixmap(0, axtt.iconObject);
node.setAnnotation(0, name, 22);
node.setAnnotation(1, cnameret.str, 22);
axtt.cmn.insertNode(node, destination, destCode);
node.setUserData(this);
......@@ -89,4 +106,8 @@ public class AXttItemAttrObject extends AXttItemBase {
}
axtt.cmn.configure();
}
public PwrtAttrRef getAttrRef() {
return aref;
}
}
......@@ -126,14 +126,14 @@ public class FlowCmn implements PlowCmnIfc {
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_x < x_left * zoom_factor - scrollOffset)
offset_x = (int)(x_left * zoom_factor) - scrollOffset;
if ( offset_y > y_high * zoom_factor - canvasHeight + 80 + scrollOffset)
offset_y = (int)(y_high * zoom_factor - canvasHeight + 80) + scrollOffset;
if ( offset_y < y_low * zoom_factor - scrollOffset)
offset_y = (int)(y_low * zoom_factor) - scrollOffset;
}
@Override
public void pageUp() {
......@@ -155,8 +155,11 @@ public class FlowCmn implements PlowCmnIfc {
int type;
switch( action) {
case MotionEvent.ACTION_UP:
type = PlowEvent.TYPE_CLICK;
case PlowCmnIfc.ACTION_CLICK:
type = PlowEvent.TYPE_CLICK;
break;
case PlowCmnIfc.ACTION_LONG_CLICK:
type = PlowEvent.TYPE_LONG_CLICK;
break;
default:
return;
......
......@@ -227,8 +227,8 @@ public class FlowCon implements FlowArrayElem {
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;
p.x = 0;
p.y = 0;
if ( temporary_ref != 0 || cc.con_type == Flow.eConType_Reference)
ref_a.draw( p, null, highlight);
else {
......
......@@ -131,7 +131,7 @@ public class FlowNode implements FlowArrayElem {
break;
case Flow.eSave_Node_n_name:
if ( token.hasMoreTokens())
n_name = token.nextToken();
n_name = token.nextToken();
else
n_name = new String();
break;
......@@ -178,7 +178,7 @@ public class FlowNode implements FlowArrayElem {
else
break;
}
buf.append(c); // TODO convert to UTF-8
buf.append(c);
c_old = c;
}
annotv[i] = new String( buf);
......
......@@ -139,4 +139,11 @@ public class GraphCmn implements PlowCmnIfc {
public void resetNodraw() {
graph.ctx.cmn.resetNodraw();
}
public int getAppMotion() {
return graph.cmn.getAppMotion();
}
public boolean getSliderActive() {
return graph.ctx.getSliderActive();
}
}
......@@ -6,6 +6,7 @@ import jpwr.pwrxtt.MainActivity;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.MotionEvent;
public class OpwinCmn implements PlowCmnIfc {
Object userData;
......@@ -17,10 +18,15 @@ public class OpwinCmn implements PlowCmnIfc {
int canvasWidth;
int offsetY = 0;
int borderY = 0;
AGraphInfo currentGraph = null;
double downX;
double downY;
float density;
public OpwinCmn( MainActivity appl, Vector<AGraphInfo> graphList) {
public OpwinCmn( MainActivity appl, Vector<AGraphInfo> graphList, float density) {
this.graphList = graphList;
this.appl = appl;
this.density = density;
}
public int type() {
return TYPE_OPWIN;
......@@ -41,10 +47,10 @@ public class OpwinCmn implements PlowCmnIfc {
if (graph.iconHeight > iconHeightMax)
iconHeightMax = graph.iconHeight;
}
int offsetX = 100;
int offsetY = 100;
int distX = iconWidthMax + 50;
int distY = iconHeightMax + 70;
int offsetX = (int)(density * 100);
int offsetY = (int)(density * 100);
int distX = iconWidthMax + (int)(density * 50);
int distY = iconHeightMax + (int)(density * 70);
int x = offsetX;
int y = offsetY;
for ( int i = 0; i < graphList.size(); i++) {
......@@ -52,7 +58,7 @@ public class OpwinCmn implements PlowCmnIfc {
graph.iconX = x;
graph.iconY = y;
graph.textX = graph.iconX + graph.iconWidth/2;
graph.textY = graph.iconY + graph.iconHeight + 15;
graph.textY = graph.iconY + graph.iconHeight + (int)(density * 15);
borderY = graph.textY + 100;
......@@ -78,7 +84,12 @@ public class OpwinCmn implements PlowCmnIfc {
for ( int i = 0; i < graphList.size(); i++) {
AGraphInfo graph = graphList.get(i);
canvas.drawBitmap(graph.bpm, graph.iconX, graph.iconY - offsetY, p);
if ( graph.inverted)
canvas.drawBitmap(graph.bpmInverted, graph.iconX, graph.iconY - offsetY, p);
else
canvas.drawBitmap(graph.bpm, graph.iconX, graph.iconY - offsetY, p);
p.setTextSize( density * 15);
int textWidth = (int) p.measureText(graph.text);
canvas.drawText(graph.text, graph.textX - textWidth/2, graph.textY - offsetY, p);
}
......@@ -100,14 +111,23 @@ public class OpwinCmn implements PlowCmnIfc {
public void pageDown() {}
public void eventHandler(int action, double fx, double fy) {
switch (action) {
case PlowEvent.TYPE_CLICK:
System.out.println("Opwin click " + fx + " " + fy);
case PlowCmnIfc.ACTION_UP:
if ( currentGraph != null) {
String cmd = "open graph " + currentGraph.graph;
if ( Math.abs(fx - downX) < 10 && Math.abs(fy - downY) < 10)
appl.command(cmd);
currentGraph.inverted = false;
currentGraph = null;
}
break;
case PlowCmnIfc.ACTION_DOWN:
for ( int i = 0; i < graphList.size(); i++) {
if ( fx > graphList.get(i).iconX && fx <= graphList.get(i).iconX + graphList.get(i).iconWidth &&
fy > graphList.get(i).iconY - offsetY && fy <= graphList.get(i).iconY + graphList.get(i).iconHeight - offsetY) {
System.out.println("Hit in icon");
String cmd = "open graph " + graphList.get(i).graph;
appl.command(cmd);
currentGraph = graphList.get(i);
currentGraph.inverted = true;
downX = fx;
downY = fy;
}
}
break;
......
......@@ -77,11 +77,16 @@ public class PlowCmn implements PlowCmnIfc {
double x = (fx + offset_x) / zoom_factor;
double y = (fy + offset_y) / zoom_factor;
int type;
boolean long_click = false;
switch( action) {
case MotionEvent.ACTION_UP:
case PlowCmnIfc.ACTION_CLICK:
type = PlowEvent.TYPE_CLICK;
break;
case PlowCmnIfc.ACTION_LONG_CLICK:
type = PlowEvent.TYPE_CLICK;
long_click = true;
break;
default:
return;
}
......@@ -92,6 +97,8 @@ public class PlowCmn implements PlowCmnIfc {
currentNode = null;
a.eventHandler(e);
if ( long_click)
e.type = PlowEvent.TYPE_LONG_CLICK;
appl.eventHandler(e);
switch (e.type) {
......
......@@ -8,6 +8,11 @@ public interface PlowCmnIfc {
public static final int TYPE_GRAPH = 3;
public static final int TYPE_EV = 4;
public static final int TYPE_OPWIN = 5;
public static final int ACTION_CLICK = 0;
public static final int ACTION_LONG_CLICK = 1;
public static final int ACTION_DOWN = 2;
public static final int ACTION_UP = 3;
public int type();
public Object getUserData();
......
......@@ -10,6 +10,7 @@ import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Rect;
import android.graphics.Typeface;
public class PlowDraw implements PlowDrawIfc {
......@@ -26,12 +27,14 @@ public class PlowDraw implements PlowDrawIfc {
Typeface[] fonts = new Typeface[6];
int canvasWidth;
int canvasHeight;
float textDensity = 1;
float lineDensity = 1;
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) {
public PlowDraw(Activity activity) {
this.activity = activity;
paint = new Paint();
......@@ -61,7 +64,7 @@ public class PlowDraw implements PlowDrawIfc {
if ( border) {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
paint.setStrokeWidth(lineDensity < 1 ? 1 : lineDensity);
canvas.drawRect(x1, y1, x2, y2, paint);
}
else {
......@@ -78,7 +81,7 @@ public class PlowDraw implements PlowDrawIfc {
if ( border) {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
paint.setStrokeWidth(lineDensity < 1 ? 1 : lineDensity);
canvas.drawArc(new RectF(x1, y1, x2, y2), 360-angel1, -angel2, false, paint);
}
else {
......@@ -93,7 +96,7 @@ public class PlowDraw implements PlowDrawIfc {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
paint.setStrokeWidth(lineDensity < 1 ? 1 : lineDensity);
canvas.drawLine(x1, y1, x2, y2, paint);
}
......@@ -114,16 +117,33 @@ public class PlowDraw implements PlowDrawIfc {
@Override
public void drawText( String text, int textColor, int textSize, int font, float x, float y) {
paint.setTextSize(textSize);
paint.setTypeface(fonts[font]);
paint.setTextSize(textDensity * textSize);
paint.setTypeface(fonts[font]);
paint.setColor(getColor(textColor));
paint.setStyle(Paint.Style.FILL);
canvas.drawText( text, x, y, paint);
int idx;
if ( (idx = text.indexOf('\n')) != -1) {
Rect tsize = new Rect();
paint.getTextBounds("A", 0, 1, tsize);
String row = text.substring(0,idx);
String rest = text.substring(idx+1);
canvas.drawText( row, x, y, paint);
while ( (idx = rest.indexOf('\n')) != -1) {
row = rest.substring(0,idx);
rest = rest.substring(idx+1);
y += tsize.height() * 1.65;
canvas.drawText( row, x, y, paint);
}
}
else
canvas.drawText( text, x, y, paint);
}
@Override
public float measureText( String text, int textSize, int font) {
paint.setTextSize(textSize);
paint.setTextSize(textDensity * textSize);
paint.setTypeface(null);
return paint.measureText(text);
......@@ -170,4 +190,9 @@ public class PlowDraw implements PlowDrawIfc {
return Color.BLACK;
}
}
public void setDensity( float textDensity, float lineDensity) {
this.textDensity = textDensity;
this.lineDensity = lineDensity;
}
}
......@@ -13,5 +13,5 @@ public interface PlowDrawIfc {
public int getCanvasWidth();
public int getCanvasHeight();
public void setCanvas(Canvas canvas);
public void setDensity(float textDensity, float lineDensity);
}
......@@ -3,6 +3,7 @@ package jpwr.app;
public class PlowEvent {
public static final int TYPE_CLICK = 1;
public static final int TYPE_OBJECT_DELETED = 2;
public static final int TYPE_LONG_CLICK = 3;
public int type;
public double x;
......
......@@ -126,7 +126,7 @@ public class PlowNode implements PlowComponent, PlowArrayElem, PlowNodeIfc {
if ( invert == this.invert)
return;
this.invert = invert;
draw();
// draw();
}
public void configure(PlowNode previous) {
......
......@@ -69,7 +69,6 @@ public class GlowDraw implements GlowDrawIfc {
public GlowDraw() {
paint = new Paint();
}
public void setActivity(Activity activity) {
......
......@@ -38,174 +38,16 @@
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();
*/
}
......@@ -218,111 +60,23 @@ public class GrowFrame implements GraphApplIfc {
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;
public void confirmYes() {}
public void openConfirmDialog( Object dyn, String text, Object object) {}
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 void openValueInputDialog( Object dyn, String text, Object object) {
}
public void openValueInputDialog( Object dyn, String text, Object object) {}
public String getObject() {
return instance;
}
......@@ -330,6 +84,9 @@ public class GrowFrame implements GraphApplIfc {
return null;
}
public void closeGraph() {}
public boolean isAuthorized(int access) {
return false;
}
}
......
......@@ -22,6 +22,7 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.view.MotionEventCompat;
import android.text.Editable;
import android.text.InputType;
import android.util.DisplayMetrics;
import android.util.FloatMath;
import android.util.Log;
import android.util.TypedValue;
......@@ -37,6 +38,7 @@ import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.view.*;
import android.widget.EditText;
import android.widget.LinearLayout;
......@@ -51,7 +53,9 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
static final int MODE_SCROLL = 1;
static final int MODE_ZOOM = 2;
String dataFile = "pwrdata";
String pwrp_exe = "pwrp_exe/";
String pwrp_load = "pwrp_load/";
String pwr_exe = "pwr_exe/";
Timer timer = new Timer();
MainView view;
Gdh gdh = null;
......@@ -107,6 +111,8 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
float eventDistance;
Vector<AGraphInfo> graphList = new Vector<AGraphInfo>();
Vector<PlowCmnIfc> cmnList = new Vector<PlowCmnIfc>();
Canvas currentCanvas = null;
float density;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -119,8 +125,10 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
view.invalidate();
timer.schedule( new MyTask(), 0, 2000);
DisplayMetrics metrics = getResources().getDisplayMetrics();
density = metrics.densityDpi / 150;
PlowCmn cmn = new PlowCmn(this, 15D);
PlowCmn cmn = new PlowCmn(this, density * 15);
gdraw = new PlowDraw(this);
cmn.setGDraw(gdraw);
currentCmn = cmn;
......@@ -196,7 +204,25 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
}
}
}
public void onBackPressed() {
if ( (opwinCmn != null && currentCmn == opwinCmn) ||
(opwinCmn == null && currentCmn == cmnList.get(0))) {
super.onBackPressed();
return;
}
// Back to opwind
if ( opwinCmn != null) {
while ( currentCmn != opwinCmn)
pushCmn();
}
else {
while ( currentCmn != cmnList.get(0))
pushCmn();
}
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
......@@ -230,10 +256,10 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
if ( aev != null && currentCmn == aev.getCmnAla()) {
// Alarm list
item_close.setVisible(true);
item_zoomin.setVisible(true);
item_zoomout.setVisible(true);
item_pageup.setVisible(true);
item_pagedown.setVisible(true);
item_zoomin.setVisible(false);
item_zoomout.setVisible(false);
item_pageup.setVisible(false);
item_pagedown.setVisible(false);
item_openobject.setVisible(true);
item_opengraph.setVisible(true);
item_openclassgraph.setVisible(true);
......@@ -246,10 +272,10 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
else if ( aev != null && currentCmn == aev.getCmnEve()) {
// Event list
item_close.setVisible(true);
item_zoomin.setVisible(true);
item_zoomout.setVisible(true);
item_pageup.setVisible(true);
item_pagedown.setVisible(true);
item_zoomin.setVisible(false);
item_zoomout.setVisible(false);
item_pageup.setVisible(false);
item_pagedown.setVisible(false);
item_openobject.setVisible(true);
item_opengraph.setVisible(true);
item_openclassgraph.setVisible(true);
......@@ -262,10 +288,10 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
else if ( currentCmn == cmnList.get(0)) {
// Navigator
item_close.setVisible(true);
item_zoomin.setVisible(true);
item_zoomout.setVisible(true);
item_pageup.setVisible(true);
item_pagedown.setVisible(true);
item_zoomin.setVisible(false);
item_zoomout.setVisible(false);
item_pageup.setVisible(false);
item_pagedown.setVisible(false);
item_openobject.setVisible(true);
item_opengraph.setVisible(true);
item_openclassgraph.setVisible(true);
......@@ -278,10 +304,10 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
else if ( currentCmn.type() == PlowCmnIfc.TYPE_FLOW) {
// Plc
item_close.setVisible(true);
item_zoomin.setVisible(true);
item_zoomout.setVisible(true);
item_pageup.setVisible(true);
item_pagedown.setVisible(true);
item_zoomin.setVisible(false);
item_zoomout.setVisible(false);
item_pageup.setVisible(false);
item_pagedown.setVisible(false);
item_openobject.setVisible(true);
item_opengraph.setVisible(true);
item_openclassgraph.setVisible(true);
......@@ -294,8 +320,8 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
else if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) {
// Graph
item_close.setVisible(true);
item_zoomin.setVisible(true);
item_zoomout.setVisible(true);
item_zoomin.setVisible(false);
item_zoomout.setVisible(false);
item_pageup.setVisible(false);
item_pagedown.setVisible(false);
item_openobject.setVisible(false);
......@@ -310,8 +336,8 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
else if ( currentCmn.type() == PlowCmnIfc.TYPE_OPWIN) {
// Operator window
item_close.setVisible(true);
item_zoomin.setVisible(true);
item_zoomout.setVisible(true);
item_zoomin.setVisible(false);
item_zoomout.setVisible(false);
item_pageup.setVisible(false);
item_pagedown.setVisible(false);
item_openobject.setVisible(false);
......@@ -325,10 +351,10 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
}
else {
// Default
item_pageup.setVisible(true);
item_zoomin.setVisible(true);
item_zoomout.setVisible(true);
item_pagedown.setVisible(true);
item_pageup.setVisible(false);
item_zoomin.setVisible(false);
item_zoomout.setVisible(false);
item_pagedown.setVisible(false);
item_openobject.setVisible(true);
item_opengraph.setVisible(true);
item_openclassgraph.setVisible(true);
......@@ -364,60 +390,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
System.out.println("Page down");
break;
case R.id.close_option:
switch(currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW: {
if ( cmnList.size() == 1) {
// Open opwin
if ( opwinCmn != null) {
currentCmn = opwinCmn;
cmnList.add(opwinCmn);
view.invalidate();
}
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;
case PlowCmnIfc.TYPE_OPWIN:
// Close app ?
break;
}
pushCmn();
break;
case R.id.openobject_option: {
System.out.println("Open object");
......@@ -546,6 +519,10 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
PwrtAttrRef aref = new PwrtAttrRef(((AXttItemObject)baseItem).getObjid());
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_CLASSGRAPH, aref));
}
else if ( baseItem instanceof AXttItemAttrObject) {
PwrtAttrRef aref = ((AXttItemAttrObject)baseItem).getAttrRef();
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_CLASSGRAPH, aref));
}
}
break;
}
......@@ -637,9 +614,9 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
}
if ( aev == null) {
PlowCmnEv cmnAla = new PlowCmnEv(appl, 15D);
PlowCmnEv cmnAla = new PlowCmnEv(appl, density * 15);
cmnAla.setGDraw(gdraw);
PlowCmnEv cmnEve = new PlowCmnEv(appl, 15D);
PlowCmnEv cmnEve = new PlowCmnEv(appl, density * 15);
cmnEve.setGDraw(gdraw);
currentCmn = cmnAla;
aev = new AEv(cmnAla, cmnEve, appl);
......@@ -661,9 +638,9 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
}
if ( aev == null) {
PlowCmnEv cmnAla = new PlowCmnEv(appl, 15D);
PlowCmnEv cmnAla = new PlowCmnEv(appl, density * 15);
cmnAla.setGDraw(gdraw);
PlowCmnEv cmnEve = new PlowCmnEv(appl, 15D);
PlowCmnEv cmnEve = new PlowCmnEv(appl, density * 15);
cmnEve.setGDraw(gdraw);
currentCmn = cmnEve;
aev = new AEv(cmnAla, cmnEve, appl);
......@@ -769,6 +746,36 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
break;
}
break;
case PlowEvent.TYPE_LONG_CLICK:
if ( e.object == null)
return;
switch(currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW:
if ( e.inIcon) {
// Open object
System.out.println("Long click event");
AXttItemBase item = (AXttItemBase)((PlowNode)e.object).getUserData();
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_ATTRIBUTES, item));
}
else {
// Open plc
System.out.println("Long click event");
AXttItemBase item = (AXttItemBase)((PlowNode)e.object).getUserData();
if ( item instanceof AXttItemObject) {
PwrtObjid oid = ((AXttItemObject)item).getObjid();
new GdhTask().execute(new GdhTaskArg(GdhTask.OPEN_FLOW, oid));
}
}
break;
case PlowCmnIfc.TYPE_EV:
break;
case PlowCmnIfc.TYPE_FLOW:
break;
case PlowCmnIfc.TYPE_OPWIN:
break;
}
break;
case PlowEvent.TYPE_OBJECT_DELETED: {
AXtt axtt = (AXtt)currentCmn.getUserData();
AXttItemBase item = (AXttItemBase)((PlowNode)e.object).getUserData();
......@@ -905,7 +912,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
String oName = node.getTraceObject();
CdhrObjid oret = gdh.nameToObjid(oName);
PlowCmn cmn = new PlowCmn(appl, 15D);
PlowCmn cmn = new PlowCmn(appl, density * 15);
cmn.setGDraw(gdraw);
currentCmn = cmn;
cmnList.add(cmn);
......@@ -976,7 +983,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
String oName = node.getTraceObject();
CdhrObjid oret = gdh.nameToObjid(oName);
PlowCmn cmn = new PlowCmn(appl, 15D);
PlowCmn cmn = new PlowCmn(appl, density * 15);
cmn.setGDraw(gdraw);
currentCmn = cmn;
cmnList.add(cmn);
......@@ -1173,10 +1180,21 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
break;
}
case OPWIN: {
// If plc window open flow for window, else for first child
// Find AppGraph object under WebHandler, search on two hierarchy levels
CdhrObjid oret = gdh.getClassList( Pwrb.cClass_WebHandler);
if (oret.oddSts()) {
CdhrString sret = gdh.objidToName(oret.objid, Cdh.mName_volumeStrict);
if ( sret.evenSts()) break;
String appUseWebDir = sret.str + ".AppUseWebDir";
CdhrBoolean bret = gdh.getObjectInfoBoolean(appUseWebDir);
if ( bret.oddSts() && bret.value == true) {
pwr_exe="pwrp_web/";
pwrp_exe="pwrp_web/";
pwrp_load="pwrp_web/";
}
for ( oret = gdh.getChild(oret.objid); oret.oddSts(); oret = gdh.getNextSibling(oret.objid)) {
CdhrClassId cret = gdh.getObjectClass(oret.objid);
if (cret.evenSts())
......@@ -1201,7 +1219,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
}
if ( graphList.size() > 0) {
opwinCmn = new OpwinCmn(appl, graphList);
opwinCmn = new OpwinCmn(appl, graphList, density);
currentCmn = opwinCmn;
cmnList.add(opwinCmn);
}
......@@ -1240,21 +1258,24 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
String image = sret.str;
if ( image.equals("")) {
info.bpm = BitmapFactory.decodeResource(getResources(), R.drawable.graph_icon);
info.bpmInverted = invertBitmap(info.bpm);
}
else {
URL url = null;
try {
if ( image.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/" + image.substring(9));
url = new URL("http://" + pwrHost + "/" + pwr_exe + image.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/" + image);
url = new URL("http://" + pwrHost + "/" + pwrp_exe + image);
}
info.bpm = BitmapFactory.decodeStream(url.openConnection().getInputStream());
info.bpmInverted = invertBitmap(info.bpm);
} catch ( IOException e) {
info.bpm = BitmapFactory.decodeResource(getResources(), R.drawable.graph_icon);
info.bpmInverted = invertBitmap(info.bpm);
System.out.println( "Unable to open file " + image + " " + url);
}
}
......@@ -1319,177 +1340,204 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
@Override
public boolean onTouchEvent(MotionEvent me) {
if ( me == null)
return true;
int action = MotionEventCompat.getActionMasked( me);
float x = MotionEventCompat.getX(me, 0);
float y = MotionEventCompat.getY(me, 0);
boolean isSustained = false;
if ( lastMotionEvent == me && eventCnt > 0) {
isSustained = true;
x = me.getX();
y = me.getY();
System.out.println("Sustain motion event: " + eventCnt + " " + lastXSpeed + " " + lastYSpeed);
if ( me == null)
return true;
int action = MotionEventCompat.getActionMasked( me);
float x = MotionEventCompat.getX(me, 0);
float y = MotionEventCompat.getY(me, 0);
boolean isSustained = false;
boolean sliderActive = false;
if ( lastMotionEvent == me && eventCnt > 0) {
isSustained = true;
x = me.getX();
y = me.getY();
System.out.println("Sustain motion event: " + eventCnt + " " + lastXSpeed + " " + lastYSpeed);
System.out.println("x,y " + lastMotionEvent.getX() + " " + lastMotionEvent.getY());
eventCnt--;
if ( eventCnt == 0) {
lastMotionEvent = null;
lastXSpeed = 0;
lastYSpeed = 0;
eventMode = MODE_NO;
}
else {
lastXSpeed = 0.8 * lastXSpeed;
lastYSpeed = 0.8 * lastYSpeed;
lastMotionEvent = MotionEvent.obtain( lastMotionEvent.getDownTime(),
lastMotionEvent.getEventTime(),
lastMotionEvent.getAction(),
(float)(lastMotionEvent.getX() + lastXSpeed * 50),
(float)(lastMotionEvent.getY() + lastYSpeed * 50),
lastMotionEvent.getMetaState());
System.out.println("x,y " + lastMotionEvent.getX() + " " + lastMotionEvent.getY());
eventCnt--;
if ( eventCnt == 0) {
lastMotionEvent = null;
lastXSpeed = 0;
lastYSpeed = 0;
eventMode = MODE_NO;
}
else {
lastXSpeed = 0.8 * lastXSpeed;
lastYSpeed = 0.8 * lastYSpeed;
lastMotionEvent = MotionEvent.obtain( lastMotionEvent.getDownTime(),
lastMotionEvent.getEventTime(),
lastMotionEvent.getAction(),
(float)(lastMotionEvent.getX() + lastXSpeed * 50),
(float)(lastMotionEvent.getY() + lastYSpeed * 50),
lastMotionEvent.getMetaState());
System.out.println("x,y " + lastMotionEvent.getX() + " " + lastMotionEvent.getY());
eventMode = MODE_SCROLL;
eventTimer.schedule( new EventTimerTask(), new Date(System.currentTimeMillis() + 50));
}
eventMode = MODE_SCROLL;
eventTimer.schedule( new EventTimerTask(), new Date(System.currentTimeMillis() + 50));
}
if ( viewOffsetY == 0) {
if ( context != null) {
TypedValue tv = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true);
viewOffsetY = getResources().getDimensionPixelSize(tv.resourceId);
int id = getResources().getIdentifier("status_bar_height", "dimen", "android");
if ( id > 0)
viewOffsetY += getResources().getDimensionPixelSize(id);
viewOffsetY = 60;
}
else
viewOffsetY = 80;
}
if ( viewOffsetY == 0) {
if ( context != null) {
Window window= getWindow();
viewOffsetY = window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
}
// System.out.println("offset : " + viewOffsetY);
switch (action) {
case MotionEvent.ACTION_MOVE:
if ( isSustained)
System.out.println("Sustained scroll");
if ( eventMode == MODE_SCROLL) {
if ( lastTouchId != me.getPointerId(0)) {
lastTouchX = x;
lastTouchY = y;
lastTouchId = me.getPointerId(0);
break;
}
if ( false /* currentCmn.type() == PlowCmnIfc.TYPE_GRAPH */){
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_MOVE, x, y-viewOffsetY)));
}
else {
System.out.println("Scroll " + x + " " + y);
if ( (int)(lastTouchY - y) != 0) {
currentCmn.scroll((int)(lastTouchX -x), (int)(lastTouchY - y));
view.invalidate();
}
lastTouchX = x;
lastTouchY = y;
lastTouchId = me.getPointerId(0);
}
if ( !isSustained) {
if ( lastMotionEvent != null) {
lastXSpeed = 0.5 * lastXSpeed + 0.5 * (x - lastMotionEvent.getX()) / (me.getEventTime() - lastMotionEvent.getEventTime());
lastYSpeed = 0.5 * lastYSpeed + 0.5 * (y - lastMotionEvent.getY()) / (me.getEventTime() - lastMotionEvent.getEventTime());
}
lastMotionEvent = MotionEvent.obtain( me.getDownTime(), me.getEventTime(),
me.getAction(), me.getX(), me.getY(),
me.getMetaState());
}
}
else if ( eventMode == MODE_ZOOM) {
float distance = eventDistance(me);
else
viewOffsetY = 56;
}
currentCmn.zoom(distance/eventDistance,
(MotionEventCompat.getX(me, 0) + MotionEventCompat.getX(me, 1))/2,
(MotionEventCompat.getY(me, 0) + MotionEventCompat.getY(me, 1))/2 + viewOffsetY);
eventDistance = distance;
switch (action) {
case MotionEvent.ACTION_MOVE:
view.invalidate();
}
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-viewOffsetY)));
}
else {
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_UP, x, y-viewOffsetY)));
}
}
else {
if ( Math.abs(x - downTouchX) < 10 && Math.abs(y - downTouchY) < 10 && currentCmn != null) {
currentCmn.eventHandler(action, x, y-viewOffsetY);
}
}
view.invalidate();
eventMode = MODE_NO;
if ( isSustained)
System.out.println("Sustained scroll");
if ( eventMode == MODE_SCROLL) {
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH &&
((GraphCmn)currentCmn).graph.getClickActive() == 1) {
//eventMode = MODE_NO;
}
if ( lastMotionEvent != null) {
System.out.println("ACTION UP, sustained motion event scheduled");
//lastXSpeed = (downTouchX - x) / (me.getDownTime() - me.getEventTime());
//lastYSpeed = (downTouchY - y) / (me.getDownTime() - me.getEventTime());
eventCnt = (int)(10 * FloatMath.sqrt((float)(lastXSpeed * lastXSpeed + lastYSpeed * lastYSpeed)));
long dt = me.getEventTime() - lastMotionEvent.getEventTime();
lastMotionEvent = MotionEvent.obtain( lastMotionEvent.getDownTime(),
lastMotionEvent.getEventTime(),
lastMotionEvent.getAction(),
(float)(lastMotionEvent.getX() + lastXSpeed * dt),
(float)(lastMotionEvent.getY() + lastYSpeed * dt),
lastMotionEvent.getMetaState());
eventTimer.schedule( new EventTimerTask(), new Date(System.currentTimeMillis() + 50));
eventMode = MODE_SCROLL;
}
if ( lastTouchId != me.getPointerId(0)) {
lastTouchX = x;
lastTouchY = y;
lastTouchId = me.getPointerId(0);
break;
case MotionEvent.ACTION_DOWN:
System.out.println("Event Down " + action + " (" + x + "," + y + ")");
lastMotionEvent = null;
lastXSpeed = 0;
lastYSpeed = 0;
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH){
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_DOWN, x, y-viewOffsetY)));
}
boolean scroll = true;
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH ) {
if ( ((GraphCmn)currentCmn).getAppMotion() == Glow.eAppMotion_Slider ||
(((GraphCmn)currentCmn).getAppMotion() == Glow.eAppMotion_Both &&
((GraphCmn)currentCmn).getSliderActive())) {
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_MOVE, x, y-viewOffsetY)));
scroll = false;
sliderActive = true;
}
}
if ( scroll && !sliderActive) {
System.out.println("Scroll " + x + " " + y);
if ( (int)(lastTouchY - y) != 0) {
currentCmn.scroll((int)(lastTouchX -x), (int)(lastTouchY - y));
view.invalidate();
}
lastTouchId = me.getPointerId(0);
lastTouchX = x;
lastTouchY = y;
downTouchX = x;
downTouchY = y;
eventMode = MODE_SCROLL;
break;
case MotionEvent.ACTION_POINTER_DOWN:
System.out.println("Event Action Pointer Down");
lastMotionEvent = null;
lastXSpeed = 0;
lastYSpeed = 0;
eventDistance = eventDistance(me);
if ( eventDistance > 10)
eventMode = MODE_ZOOM;
break;
case MotionEvent.ACTION_POINTER_UP:
System.out.println("Event Action Pointer Up");
eventMode = MODE_SCROLL;
break;
lastTouchId = me.getPointerId(0);
}
if ( !isSustained && !sliderActive) {
if ( lastMotionEvent != null) {
lastXSpeed = 0.5 * lastXSpeed + 0.5 * (x - lastMotionEvent.getX()) / (me.getEventTime() - lastMotionEvent.getEventTime());
lastYSpeed = 0.5 * lastYSpeed + 0.5 * (y - lastMotionEvent.getY()) / (me.getEventTime() - lastMotionEvent.getEventTime());
}
lastMotionEvent = MotionEvent.obtain( me.getDownTime(), me.getEventTime(),
me.getAction(), me.getX(), me.getY(),
me.getMetaState());
}
}
return true;
else if ( eventMode == MODE_ZOOM) {
float distance = eventDistance(me);
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH &&
((GraphCmn)currentCmn).getAppMotion() == Glow.eAppMotion_Slider)
currentCmn.zoom(distance/eventDistance);
else
currentCmn.zoom(distance/eventDistance,
(MotionEventCompat.getX(me, 0) + MotionEventCompat.getX(me, 1))/2,
(MotionEventCompat.getY(me, 0) + MotionEventCompat.getY(me, 1))/2 + viewOffsetY);
eventDistance = distance;
view.invalidate();
}
break;
case MotionEvent.ACTION_UP:
if ( currentCmn == null)
break;
if ( 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-viewOffsetY)));
}
else {
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_UP, x, y-viewOffsetY)));
}
}
else if ( currentCmn.type() == PlowCmnIfc.TYPE_OPWIN){
currentCmn.eventHandler(PlowCmnIfc.ACTION_UP, x, y-viewOffsetY);
}
else {
if ( Math.abs(x - downTouchX) < 10 && Math.abs(y - downTouchY) < 10 && currentCmn != null &&
me.getEventTime() - me.getDownTime() > 500) {
currentCmn.eventHandler(PlowCmnIfc.ACTION_LONG_CLICK, x, y-viewOffsetY);
}
else if ( Math.abs(x - downTouchX) < 10 && Math.abs(y - downTouchY) < 10 && currentCmn != null) {
currentCmn.eventHandler(PlowCmnIfc.ACTION_CLICK, x, y-viewOffsetY);
}
}
view.invalidate();
eventMode = MODE_NO;
sliderActive = false;
if ( lastMotionEvent != null) {
System.out.println("ACTION UP, sustained motion event scheduled");
//lastXSpeed = (downTouchX - x) / (me.getDownTime() - me.getEventTime());
//lastYSpeed = (downTouchY - y) / (me.getDownTime() - me.getEventTime());
eventCnt = (int)(10 * FloatMath.sqrt((float)(lastXSpeed * lastXSpeed + lastYSpeed * lastYSpeed)));
long dt = me.getEventTime() - lastMotionEvent.getEventTime();
lastMotionEvent = MotionEvent.obtain( lastMotionEvent.getDownTime(),
lastMotionEvent.getEventTime(),
lastMotionEvent.getAction(),
(float)(lastMotionEvent.getX() + lastXSpeed * dt),
(float)(lastMotionEvent.getY() + lastYSpeed * dt),
lastMotionEvent.getMetaState());
eventTimer.schedule( new EventTimerTask(), new Date(System.currentTimeMillis() + 50));
eventMode = MODE_SCROLL;
}
break;
case MotionEvent.ACTION_DOWN:
System.out.println("offset : " + viewOffsetY + " (x,y) (" + x + "," + y + ")");
lastMotionEvent = null;
lastXSpeed = 0;
lastYSpeed = 0;
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) {
new GdhTask().execute(new GdhTaskArg(GdhTask.EVENTHANDLER,
new GdhEventArg(GraphCmn.ACTION_DOWN, x, y-viewOffsetY)));
}
else if ( currentCmn.type() == PlowCmnIfc.TYPE_OPWIN) {
currentCmn.eventHandler(PlowCmnIfc.ACTION_DOWN, x, y-viewOffsetY);
view.invalidate();
}
lastTouchId = me.getPointerId(0);
lastTouchX = x;
lastTouchY = y;
downTouchX = x;
downTouchY = y;
eventMode = MODE_SCROLL;
break;
case MotionEvent.ACTION_POINTER_DOWN:
System.out.println("Event Action Pointer Down");
lastMotionEvent = null;
lastXSpeed = 0;
lastYSpeed = 0;
eventDistance = eventDistance(me);
if ( eventDistance > 10)
eventMode = MODE_ZOOM;
break;
case MotionEvent.ACTION_POINTER_UP:
System.out.println("Event Action Pointer Up");
eventMode = MODE_SCROLL;
break;
}
return true;
}
private float eventDistance(MotionEvent me) {
float x = MotionEventCompat.getX(me, 0) - MotionEventCompat.getX(me, 1);
......@@ -1535,7 +1583,7 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
protected void onDraw( Canvas canvas) {
if ( currentCmn != null) {
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) {
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH) {
if ( bitmap == null) {
bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
drawCanvas = new Canvas(bitmap);
......@@ -1546,24 +1594,40 @@ public class MainActivity extends Activity implements PlowAppl, GraphApplIfc, Gd
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);
}
Canvas currentCanvas = getHolder().lockCanvas();
//if ( currentCanvas == null)
// currentCanvas = getHolder().lockCanvas();
if ( currentCanvas != null) {
if ( currentCmn.type() == PlowCmnIfc.TYPE_GRAPH)
currentCanvas.drawColor(graph.cmn.gdraw.getColor(graph.cmn.background_color));
else
currentCanvas.drawColor(Color.WHITE);
if ( currentCmn.type() == PlowCmnIfc.TYPE_FLOW)
gdraw.setDensity(1, density);
else
gdraw.setDensity(density, density);
currentCmn.setCanvas(currentCanvas);
currentCmn.draw();
/* Test
Paint paint = new Paint();
currentCanvas.drawText( "Density " + density, 10, 100, paint);
*/
getHolder().unlockCanvasAndPost(currentCanvas);
// currentCanvas = getHolder().lockCanvas();
}
}
}
}
}
}
......@@ -1612,8 +1676,8 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
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()));
url = new URL("http://" + pwrHost + "/" + pwrp_load + filename);
reader = new BufferedReader(new InputStreamReader(url.openStream(), "ISO-8859-1"));
} catch ( IOException e) {
System.out.println( "Unable to open file " + filename + " " + url);
return;
......@@ -1627,9 +1691,11 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
if ( object != null) {
FlowNode node = (FlowNode)ctx.getObject(object);
fcmn.select(node);
node.setSelect(true);
ctx.centerObject(node);
if ( node != null) {
fcmn.select(node);
node.setSelect(true);
ctx.centerObject(node);
}
}
......@@ -1655,13 +1721,13 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
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));
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);
url = new URL("http://" + pwrHost + "/" + pwrp_exe + filename);
}
reader = new BufferedReader(new InputStreamReader(url.openStream()));
reader = new BufferedReader(new InputStreamReader(url.openStream(), "ISO-8859-1"));
} catch ( IOException e) {
System.out.println( "Unable to open file " + filename + " " + url);
return;
......@@ -1747,13 +1813,13 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
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));
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);
url = new URL("http://" + pwrHost + "/" + pwrp_exe + filename);
}
reader = new BufferedReader(new InputStreamReader(url.openStream()));
reader = new BufferedReader(new InputStreamReader(url.openStream(), "ISO-8859-1"));
} catch ( IOException e) {
System.out.println( "Unable to open file " + filename + " " + url);
return null;
......@@ -2007,7 +2073,11 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
graphObject.removeElementAt(graphObject.size()-1);
currentCmn = cmnList.get(cmnList.size()-2);
cmnList.removeElementAt(cmnList.size()-1);
view.invalidate();
//view.invalidate();
}
public boolean isAuthorized(int access) {
return gdh.isAuthorized(access);
}
public void invalidateView() {
......@@ -2023,4 +2093,84 @@ System.out.println("MainActivity TimerTask " + currentCmn.type());
public PlowCmnIfc getCurrentCmn() {
return currentCmn;
}
public Bitmap invertBitmap(Bitmap src) {
Bitmap output = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
int A, R, G, B;
int pixelColor;
int height = src.getHeight();
int width = src.getWidth();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
pixelColor = src.getPixel(x, y);
A = Color.alpha(pixelColor);
R = Math.max( Color.red(pixelColor) - 50, 0);
G = Math.max( Color.green(pixelColor) - 50, 0);
B = Math.max( Color.blue(pixelColor) - 50, 0);
output.setPixel(x, y, Color.argb(A, R, G, B));
}
}
return output;
}
public void pushCmn() {
switch(currentCmn.type()) {
case PlowCmnIfc.TYPE_PLOW: {
if ( cmnList.size() == 1) {
// Open opwin
if ( opwinCmn != null) {
currentCmn = opwinCmn;
cmnList.add(opwinCmn);
view.invalidate();
}
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;
case PlowCmnIfc.TYPE_OPWIN:
// Close app ?
break;
}
}
}
......@@ -591,7 +591,7 @@ public class Dyn {
public static final int ePwrStatus_Error = 3;
public static final int ePwrStatus_Fatal = 4;
public static final boolean debug = false;
public static final boolean debug = true;
Vector<DynElem> elements = new Vector<DynElem>();
GraphIfc graph;
......@@ -3174,6 +3174,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Click:
dyn.object = object;
......@@ -6361,6 +6364,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -6447,6 +6453,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -6533,14 +6542,19 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
dyn.graph.setClickActive(1);
break;
case Glow.eEvent_MB1Up:
object.setColorInverse( 0);
dyn.repaintNow = true;
dyn.graph.setClickActive( 0);
break;
case Glow.eEvent_MB1Click:
if ( (dyn.action_type1 & Dyn.mActionType1_Confirm) != 0)
......@@ -6613,6 +6627,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down: {
object.setColorInverse( 1);
......@@ -6632,7 +6649,7 @@ public class Dyn {
break;
}
if ( sts.evenSts())
System.out.println( "SetDig: " + pname.name);
System.out.println( "StoDig: " + pname.name);
break;
}
case Glow.eEvent_MB1Up: {
......@@ -6710,6 +6727,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -6783,6 +6803,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -6858,6 +6881,9 @@ public class Dyn {
if ( (dyn.action_type1 & Dyn.mActionType1_Confirm) == 0)
return 1;
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
break;
......@@ -6926,6 +6952,10 @@ public class Dyn {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -7119,6 +7149,10 @@ public class Dyn {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -7374,6 +7408,9 @@ public class Dyn {
}
public int action( GlowArrayElem o, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
o.setColorInverse( 1);
......@@ -7466,6 +7503,9 @@ public class Dyn {
}
public int action( GlowArrayElem o, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
......@@ -7602,7 +7642,9 @@ public class Dyn {
}
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -8223,6 +8265,9 @@ public class Dyn {
}
public int action( GlowArrayElem o, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Click:
......@@ -8859,6 +8904,10 @@ public class Dyn {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Click:
if ( menu_object != null) {
......
......@@ -73,6 +73,7 @@ public class Glow {
public static final int eType_AnnotType = 21;
public static final int eType_DynType2 = 22;
public static final int eType_ActionType2 = 23;
public static final int eType_AppMotion = 24;
public static final int eCtxType_Glow = 0;
public static final int eCtxType_Brow = 1;
......@@ -243,6 +244,10 @@ public class Glow {
public static final int eHotIndication_DarkColor = 2;
public static final int eHotIndication_LightColor = 3;
public static final int eAppMotion_Scroll = 0;
public static final int eAppMotion_Slider = 1;
public static final int eAppMotion_Both = 2;
public static final int eDrawType_Line = 0;
public static final int eDrawType_LineRed = 1;
public static final int eDrawType_LineGray = 2;
......@@ -772,6 +777,7 @@ public class Glow {
public static final int eSave_Ctx_version = 137;
public static final int eSave_Ctx_hot_indication = 138;
public static final int eSave_Ctx_tiptext_size = 139;
public static final int eSave_Ctx_app_motion = 140;
public static final int eSave_Ctx_comment = 199;
public static final int eSave_Array_a = 200;
public static final int eSave_NodeClass_nc_name = 300;
......
......@@ -53,6 +53,7 @@ public class Graph implements GraphIfc, GrowApplIfc {
public double scan_time = 1;
GrowCmn[] cmnStack = new GrowCmn[10];
int cmnStackCnt = 0;
int clickActive = 0;
public Graph(GraphApplIfc appl, Gdh gdh) {
this.appl = appl;
......@@ -504,7 +505,7 @@ public class Graph implements GraphIfc, GrowApplIfc {
}
public boolean isAuthorized(int access) {
return true;
return appl.isAuthorized(access);
}
public double getScanTime() {
......@@ -538,4 +539,12 @@ public class Graph implements GraphIfc, GrowApplIfc {
ctx = (GrowCtx)cmn.ctx;
}
}
public void setClickActive(int active) {
clickActive = active;
}
public int getClickActive() {
return clickActive;
}
}
......@@ -45,4 +45,5 @@ public interface GraphApplIfc {
public String getObject();
public Object loadGrowCtx( String file);
public void closeGraph();
public boolean isAuthorized(int access);
}
......@@ -63,4 +63,5 @@ public interface GraphIfc {
public boolean isAuthorized(int access);
public double getScanTime();
public String getCommand(String cmd);
public void setClickActive(int active);
}
......@@ -99,6 +99,7 @@ public class GrowCmn {
int translate_on;
int input_focus_mark;
int hot_indication;
int app_motion = Glow.eAppMotion_Both;
Object userdata;
GlowArrayElem callback_object;
int callback_object_type;
......@@ -119,7 +120,7 @@ public class GrowCmn {
public GrowCmn( GrowCtxIfc ctx, GrowApplIfc appl) {
this.ctx = ctx;
this.appl = appl;
this.debug = false;
this.debug = true;
this.antiAliasing = true;
mw.window_width = getWidth();
mw.window_height = getHeight();
......@@ -148,4 +149,7 @@ public class GrowCmn {
public String getOwner() {
return owner;
}
public int getAppMotion() {
return app_motion;
}
}
......@@ -140,6 +140,9 @@ public class GrowCtx implements GrowCtxIfc {
break;
case Glow.eSave_Ctx_tiptext_size:
break;
case Glow.eSave_Ctx_app_motion:
cmn.app_motion = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_Ctx_grow:
open_grow( reader);
grow_loaded = true;
......@@ -826,6 +829,14 @@ public class GrowCtx implements GrowCtxIfc {
e.setSource( source, owner);
}
public boolean getSliderActive() {
return sliderActive;
}
public void setSliderActive( boolean active) {
sliderActive = active;
}
}
......
......@@ -66,4 +66,5 @@ public interface GrowCtxIfc {
public void traceScan();
public boolean traceStarted();
public void setSubwindowSource( String name, String source, String owner);
public void setSliderActive( boolean active);
}
......@@ -198,6 +198,7 @@ public class GrowScrollBar extends GrowRect {
start_pos = fy;
start_value = bar_value;
movement_active = 1;
cmn.ctx.setSliderActive(true);
}
break;
case Glow.eDir_Horizontal:
......@@ -206,12 +207,14 @@ public class GrowScrollBar extends GrowRect {
start_pos = fx;
start_value = bar_value;
movement_active = 1;
cmn.ctx.setSliderActive(true);
}
break;
}
break;
case Glow.eEvent_MB1Up:
movement_active = 0;
cmn.ctx.setSliderActive(false);
break;
case Glow.eEvent_ButtonMotion:
if ( movement_active != 0) {
......
......@@ -442,9 +442,13 @@ public class GrowWindow extends GrowRect implements GrowScrollBarIfc {
}
v_scrollbar.set_shadow( shadow);
}
else {
if ( windowCmn != null)
else if ( v_scrollbar != null) {
if ( windowCmn != null) {
v_scrollbar.set_range( wctx_y0 * windowCmn.mw.subwindow_scale, wctx_y1 * window_scale);
v_scrollbar.set_value( wctx_y0 * windowCmn.mw.subwindow_scale, y_high -
(y_low + y_low_offs) - scrollbar_width * horizontal_scrollbar);
v_value = wctx_y0 * windowCmn.mw.subwindow_scale;
}
}
if ( horizontal_scrollbar != 0 && h_scrollbar == null) {
......@@ -467,9 +471,13 @@ public class GrowWindow extends GrowRect implements GrowScrollBarIfc {
}
h_scrollbar.set_shadow( shadow);
}
else {
if ( windowCmn != null)
else if ( h_scrollbar != null) {
if ( windowCmn != null) {
h_scrollbar.set_range( wctx_x0 * windowCmn.mw.subwindow_scale, wctx_x1 * windowCmn.mw.subwindow_scale);
h_scrollbar.set_value( wctx_x0 * windowCmn.mw.subwindow_scale,
x_right - x_left - scrollbar_width * vertical_scrollbar);
h_value = wctx_x0 * windowCmn.mw.subwindow_scale;
}
}
}
......
......@@ -30,6 +30,7 @@ copy :
lib :
exe : $(bld_dir)/control_pwrrt $(bld_dir)/control_pwr $(bld_dir)/control_pwrdemo $(bld_dir)/control_pwrsev
rpi : $(bld_dir)/control_pwrrpi
clean :
......@@ -60,5 +61,10 @@ $(bld_dir)/control_pwrsev : ../../../pwrsev/control
@ ../../../pwrsev/build.sh
@ cp $(source) $(target)
$(bld_dir)/control_pwrrpi : ../../../pwrrpi/control
@ echo "build $(target)"
@ ../../../pwrrpi/build.sh
@ cp $(source) $(target)
......@@ -329,6 +329,15 @@ SObject pwrb:Class
Attr Flags = 0
EndBody
EndObject
!/**
! If AppUseWebDir is set all files used by the Android application is
! read from pwrp_web.
!*/
Object AppUseWebDir $Attribute 42
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
EndObject
!
! Template for WebHandler
......
......@@ -862,6 +862,12 @@ static attrnav_sEnumElement elem_hot_indication[] = {
{ (int) glow_eHotIndication_LightColor, "LightColor"},
{ 0, ""}};
static attrnav_sEnumElement elem_app_motion[] = {
{ (int) glow_eAppMotion_Scroll, "Scroll"},
{ (int) glow_eAppMotion_Slider, "Slider"},
{ (int) glow_eAppMotion_Both, "Both"},
{ 0, ""}};
static attrnav_sEnumElement elem_annot_type[] = {
{ (int) glow_eAnnotType_OneLine, "OneLine"},
{ (int) glow_eAnnotType_MultiLine, "MultiLine"},
......@@ -995,6 +1001,7 @@ static attrnav_sEnum enum_types[] = {
{ (int) ge_eAttrType_CurveDataType, (attrnav_sEnumElement *) &elem_curve_datatype},
{ (int) glow_eType_Gradient, (attrnav_sEnumElement *) &elem_gradient},
{ (int) glow_eType_HotIndication, (attrnav_sEnumElement *) &elem_hot_indication},
{ (int) glow_eType_AppMotion, (attrnav_sEnumElement *) &elem_app_motion},
{ (int) glow_eType_AnnotType, (attrnav_sEnumElement *) &elem_annot_type},
{ (int) ge_eAttrType_OptionMenuType, (attrnav_sEnumElement *) &elem_optionmenu_type},
{ 0, NULL}};
......@@ -1063,6 +1070,7 @@ int attrnav_attr_string_to_value( int type_id, char *value_str,
case glow_eType_TextSize:
case glow_eType_Gradient:
case glow_eType_HotIndication:
case glow_eType_AppMotion:
case ge_eAttrType_DynType1:
case ge_eAttrType_DynType2:
case ge_eAttrType_DynTypeTone:
......@@ -1150,6 +1158,7 @@ void attrnav_attrvalue_to_string( int type_id, void *value_ptr,
case glow_eType_TextSize:
case glow_eType_Gradient:
case glow_eType_HotIndication:
case glow_eType_AppMotion:
case ge_eAttrType_AnimSequence:
case ge_eAttrType_LimitType:
case ge_eAttrType_ScaleType:
......@@ -2235,6 +2244,7 @@ ItemLocal::ItemLocal( AttrNav *attrnav, const char *item_name, const char *attr,
case glow_eType_TextSize:
case glow_eType_Gradient:
case glow_eType_HotIndication:
case glow_eType_AppMotion:
case ge_eAttrType_DynType1:
case ge_eAttrType_DynType2:
case ge_eAttrType_DynTypeTone:
......
......@@ -101,7 +101,8 @@ typedef enum {
glow_eType_HotIndication, //!< Type is glow_eHotIndication
glow_eType_AnnotType, //!< Type is glow_eAnnotType
glow_eType_DynType2, //!< Type of dynamics mask 2
glow_eType_ActionType2 //!< Type of action mask 2
glow_eType_ActionType2, //!< Type of action mask 2
glow_eType_AppMotion //!< Type is glow_eAppMotion
} glow_eType;
//! Type of Ctx class
......@@ -409,6 +410,13 @@ typedef enum {
glow_eHotIndication_LightColor //!< Lighter color for hot objects
} glow_eHotIndication;
//! Action for app motion event
typedef enum {
glow_eAppMotion_Scroll, //!< Scrolling
glow_eAppMotion_Slider, //!< Slider
glow_eAppMotion_Both //!< Both slider and scrolling
} glow_eAppMotion;
//! Color index for a color
/*! The drawtype is index in an array that contains the gc for colors in the color palette.
......@@ -1128,6 +1136,7 @@ typedef enum {
glow_eSave_Ctx_version = 137,
glow_eSave_Ctx_hot_indication = 138,
glow_eSave_Ctx_tiptext_size = 139,
glow_eSave_Ctx_app_motion = 140,
glow_eSave_Ctx_comment = 199,
glow_eSave_Array_a = 200,
glow_eSave_NodeClass_nc_name = 300,
......
......@@ -98,7 +98,8 @@ GlowCtx::GlowCtx( const char *ctx_name, double zoom_fact, int offs_x, int offs_y
default_hot_mode(glow_eHotMode_SingleObject), hot_found(0),
userdata_save_callback(0), userdata_open_callback(0), userdata_copy_callback(0),
version(GLOW_VERSION), inputfocus_object(0), is_component(0), comment(0),
hot_indication(glow_eHotIndication_LightColor), tiptext_size(2), eventlog_callback(0)
hot_indication(glow_eHotIndication_LightColor), tiptext_size(2), app_motion(glow_eAppMotion_Both),
eventlog_callback(0)
{
strcpy(name, ctx_name);
memset( (void *)event_callback, 0, sizeof(event_callback));
......@@ -214,6 +215,7 @@ int GlowCtx::save( char *filename, glow_eSaveMode mode)
fp << int(glow_eSave_Ctx_version) << FSPACE << version << endl;
fp << int(glow_eSave_Ctx_hot_indication) << FSPACE << hot_indication << endl;
fp << int(glow_eSave_Ctx_tiptext_size) << FSPACE << tiptext_size << endl;
fp << int(glow_eSave_Ctx_app_motion) << FSPACE << app_motion << endl;
if ( ctx_type == glow_eCtxType_Grow)
{
fp << int(glow_eSave_Ctx_grow) << endl;
......@@ -361,6 +363,7 @@ int GlowCtx::open( char *filename, glow_eSaveMode mode)
case glow_eSave_Ctx_version: fp >> version; break;
case glow_eSave_Ctx_hot_indication: fp >> tmp; hot_indication = (glow_eHotIndication)tmp; break;
case glow_eSave_Ctx_tiptext_size: fp >> tiptext_size; break;
case glow_eSave_Ctx_app_motion: fp >> tmp; app_motion = (glow_eAppMotion)tmp; break;
case glow_eSave_Ctx_grow:
((GrowCtx *)this)->open_grow( fp);
grow_loaded = 1;
......
......@@ -847,6 +847,7 @@ class GlowCtx {
CtxComment *comment;
glow_eHotIndication hot_indication; //!< Specification of how hots object should be drawn.
int tiptext_size; //!< Size of tooltip text
glow_eAppMotion app_motion; //!< Action for app motion event.
glow_tEventLogCb eventlog_callback; //!< Callback function to log events.
static int eventlog_enabled; //!< Event logging enabled.
......
......@@ -3261,6 +3261,11 @@ int grow_GetGraphAttrInfo( grow_tCtx ctx, grow_sAttrInfo **info,
attrinfo[i].type = glow_eType_TextSize;
attrinfo[i++].size = sizeof( ctx->tiptext_size);
strcpy( attrinfo[i].name, "AppMotion");
attrinfo[i].value_p = &ctx->app_motion;
attrinfo[i].type = glow_eType_AppMotion;
attrinfo[i++].size = sizeof( ctx->app_motion);
attrinfo[i].info_type = grow_eInfoType_End;
*attr_cnt = i;
*info = attrinfo;
......
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