Package com.cburch.draw.tools

Source Code of com.cburch.draw.tools.RectangleTool

/* Copyright (c) 2010, Carl Burch. License information is located in the
* com.cburch.logisim.Main source code and at www.cburch.com/logisim/. */

package com.cburch.draw.tools;

import java.awt.Graphics;
import java.util.List;

import javax.swing.Icon;

import com.cburch.draw.model.CanvasObject;
import com.cburch.draw.shapes.DrawAttr;
import com.cburch.draw.shapes.Rectangle;
import com.cburch.logisim.data.Attribute;
import com.cburch.logisim.util.Icons;

public class RectangleTool extends RectangularTool {
    private DrawingAttributeSet attrs;

    public RectangleTool(DrawingAttributeSet attrs) {
        this.attrs = attrs;
    }

    @Override
    public Icon getIcon() {
        return Icons.getIcon("drawrect.svg");
    }

    @Override
    public List<Attribute<?>> getAttributes() {
        return DrawAttr.getFillAttributes(attrs.getValue(DrawAttr.PAINT_TYPE));
    }

    @Override
    public CanvasObject createShape(int x, int y, int w, int h) {
        return attrs.applyTo(new Rectangle(x, y, w, h));
    }

    @Override
    public void drawShape(Graphics g, int x, int y, int w, int h) {
        g.drawRect(x, y, w, h);
    }

    @Override
    public void fillShape(Graphics g, int x, int y, int w, int h) {
        g.fillRect(x, y, w, h);
    }
}
TOP

Related Classes of com.cburch.draw.tools.RectangleTool

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.