use of org.hwyl.sexytopo.model.sketch.SketchTool in project sexytopo by richsmith.
the class GraphActivity method selectSketchTool.
private void selectSketchTool(SketchTool toSelect) {
SharedPreferences preferences = getSharedPreferences(DISPLAY_PREFERENCES_KEY, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString(SKETCH_TOOL_PREFERENCE_KEY, toSelect.toString());
editor.apply();
graphView.setSketchTool(toSelect);
for (SketchTool sketchTool : SketchTool.values()) {
View button = findViewById(sketchTool.getId());
if (button == null) {
// some tools are not linked to a toolbar button
continue;
}
if (sketchTool == toSelect) {
button.getBackground().setColorFilter(0xffffffff, PorterDuff.Mode.SRC_ATOP);
} else {
button.getBackground().clearColorFilter();
}
}
}
use of org.hwyl.sexytopo.model.sketch.SketchTool 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;
}
use of org.hwyl.sexytopo.model.sketch.SketchTool in project sexytopo by richsmith.
the class GraphActivity method initialiseSketchTool.
private void initialiseSketchTool() {
SharedPreferences preferences = getSharedPreferences(DISPLAY_PREFERENCES_KEY, Context.MODE_PRIVATE);
String selected = preferences.getString(SKETCH_TOOL_PREFERENCE_KEY, null);
SketchTool sketchTool = (selected == null) ? DEFAULT_SKETCH_TOOL_SELECTION : SketchTool.valueOf(selected);
selectSketchTool(sketchTool);
}
Aggregations