Search in sources :

Example 1 with GraphView

use of org.hwyl.sexytopo.control.graph.GraphView in project sexytopo by richsmith.

the class GraphActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    updatedReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            syncGraphWithSurvey();
        }
    };
    createdReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            handleAutoRecentre();
        }
    };
    setContentView(R.layout.activity_graph);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    for (int id : BUTTON_IDS) {
        View button = findViewById(id);
        button.setOnClickListener(this);
    }
    View button = findViewById(R.id.buttonSymbolToolbarClose);
    button.setOnClickListener(this);
    graphView = findViewById(R.id.graphView);
    graphView.setActivity(this);
    preferences = getSharedPreferences("display", Context.MODE_PRIVATE);
    // Needs to be threaded so it is only run once we know height and width
    graphView.post(this::setViewLocation);
}
Also used : Context(android.content.Context) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) ImageView(android.widget.ImageView) View(android.view.View) GraphView(org.hwyl.sexytopo.control.graph.GraphView)

Example 2 with GraphView

use of org.hwyl.sexytopo.control.graph.GraphView in project sexytopo by richsmith.

the class GraphActivity method handleAction.

public boolean handleAction(int itemId) {
    GraphView graphView = findViewById(R.id.graphView);
    graphView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    for (BrushColour brushColour : BrushColour.values()) {
        if (brushColour.getId() == itemId) {
            selectBrushColour(brushColour);
            if (!graphView.getSketchTool().usesColour()) {
                selectSketchTool(SketchTool.DRAW);
            }
            return true;
        }
    }
    SketchTool alreadySelectedTool = graphView.getSketchTool();
    for (SketchTool sketchTool : SketchTool.values()) {
        if (sketchTool.getId() == itemId) {
            if (alreadySelectedTool == SketchTool.SYMBOL && sketchTool == SketchTool.SYMBOL) {
                toggleSymbolToolbar();
            } else {
                selectSketchTool(sketchTool);
            }
            return true;
        }
    }
    for (Symbol symbol : Symbol.values()) {
        if (itemId == symbol.getBitmapId()) {
            selectSketchTool(SketchTool.SYMBOL);
            selectSymbol(symbol);
            return true;
        }
    }
    if (itemId == R.id.buttonSymbolToolbarClose) {
        setSymbolToolbarOpen(false);
        return true;
    } else if (itemId == R.id.buttonZoomIn) {
        graphView.adjustZoomBy(ZOOM_INCREMENT);
        graphView.invalidate();
        return true;
    } else if (itemId == R.id.buttonZoomOut) {
        graphView.adjustZoomBy(ZOOM_DECREMENT);
        graphView.invalidate();
        return true;
    } else if (itemId == R.id.buttonUndo) {
        graphView.undo();
        return true;
    } else if (itemId == R.id.buttonRedo) {
        graphView.redo();
        return true;
    } else if (itemId == R.id.buttonMenu) {
        openDisplayMenu();
        return true;
    } else if (itemId == R.id.buttonCentreView) {
        graphView.centreViewOnActiveStation();
        graphView.invalidate();
        return true;
    } else if (itemId == R.id.buttonDeleteLastLeg) {
        getSurvey().undoAddLeg();
        syncGraphWithSurvey();
        return true;
    }
    return false;
}
Also used : SketchTool(org.hwyl.sexytopo.model.sketch.SketchTool) BrushColour(org.hwyl.sexytopo.model.sketch.BrushColour) Symbol(org.hwyl.sexytopo.model.sketch.Symbol) GraphView(org.hwyl.sexytopo.control.graph.GraphView)

Aggregations

GraphView (org.hwyl.sexytopo.control.graph.GraphView)2 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 Intent (android.content.Intent)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 BrushColour (org.hwyl.sexytopo.model.sketch.BrushColour)1 SketchTool (org.hwyl.sexytopo.model.sketch.SketchTool)1 Symbol (org.hwyl.sexytopo.model.sketch.Symbol)1