Search in sources :

Example 1 with Symbol

use of org.hwyl.sexytopo.model.sketch.Symbol in project sexytopo by richsmith.

the class GraphActivity method initialiseSymbolToolbar.

private void initialiseSymbolToolbar() {
    Symbol.setResources(getResources());
    LinearLayout buttonPanel = findViewById(R.id.symbolToolbarButtonPanel);
    buttonPanel.removeAllViews();
    for (Symbol symbol : Symbol.values()) {
        LayoutInflater inflater = LayoutInflater.from(this);
        LinearLayout linearLayout = (LinearLayout) (inflater.inflate(R.layout.tool_button, buttonPanel, false));
        ImageButton imageButton = (ImageButton) linearLayout.getChildAt(0);
        // bit hacky :P
        imageButton.setId(symbol.getBitmapId());
        imageButton.setImageBitmap(symbol.getButtonBitmap());
        imageButton.setOnClickListener(this);
        buttonPanel.addView(linearLayout);
    }
    buttonPanel.invalidate();
}
Also used : ImageButton(android.widget.ImageButton) Symbol(org.hwyl.sexytopo.model.sketch.Symbol) LayoutInflater(android.view.LayoutInflater) LinearLayout(android.widget.LinearLayout)

Example 2 with Symbol

use of org.hwyl.sexytopo.model.sketch.Symbol in project sexytopo by richsmith.

the class GraphActivity method initialiseSymbolTool.

private void initialiseSymbolTool() {
    Symbol.setResources(getResources());
    String selected = preferences.getString(SYMBOL_PREFERENCE_KEY, null);
    Symbol selectedSymbol = (selected == null) ? Symbol.getDefault() : Symbol.valueOf(selected);
    selectSymbol(selectedSymbol);
}
Also used : Symbol(org.hwyl.sexytopo.model.sketch.Symbol)

Example 3 with Symbol

use of org.hwyl.sexytopo.model.sketch.Symbol 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)

Example 4 with Symbol

use of org.hwyl.sexytopo.model.sketch.Symbol in project sexytopo by richsmith.

the class SketchJsonTranslater method toSymbolDetail.

public static SymbolDetail toSymbolDetail(JSONObject json) throws JSONException {
    Colour colour = Colour.valueOf(json.getString(COLOUR_TAG));
    Coord2D location = toCoord2D(json.getJSONObject(POSITION_TAG));
    Symbol symbol = Symbol.valueOf(json.getString(SYMBOL_ID_TAG));
    float size = (float) (json.has(SIZE_TAG) ? json.getDouble(SIZE_TAG) : 1);
    SymbolDetail symbolDetail = new SymbolDetail(location, symbol, colour, size);
    return symbolDetail;
}
Also used : SymbolDetail(org.hwyl.sexytopo.model.sketch.SymbolDetail) Symbol(org.hwyl.sexytopo.model.sketch.Symbol) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Colour(org.hwyl.sexytopo.model.sketch.Colour)

Aggregations

Symbol (org.hwyl.sexytopo.model.sketch.Symbol)4 LayoutInflater (android.view.LayoutInflater)1 ImageButton (android.widget.ImageButton)1 LinearLayout (android.widget.LinearLayout)1 GraphView (org.hwyl.sexytopo.control.graph.GraphView)1 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)1 BrushColour (org.hwyl.sexytopo.model.sketch.BrushColour)1 Colour (org.hwyl.sexytopo.model.sketch.Colour)1 SketchTool (org.hwyl.sexytopo.model.sketch.SketchTool)1 SymbolDetail (org.hwyl.sexytopo.model.sketch.SymbolDetail)1