
org.yaoqiang.graph.shape.GroupShape Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yaoqiang-bpmn-editor Show documentation
Show all versions of yaoqiang-bpmn-editor Show documentation
an Open Source BPMN 2.0 Modeler
package org.yaoqiang.graph.shape;
import java.awt.AlphaComposite;
import java.awt.Rectangle;
import org.yaoqiang.util.Constants;
import com.mxgraph.canvas.mxGraphics2DCanvas;
import com.mxgraph.shape.mxBasicShape;
import com.mxgraph.util.mxConstants;
import com.mxgraph.util.mxUtils;
import com.mxgraph.view.mxCellState;
/**
* GroupShape
*
* @author Shi Yaoqiang([email protected])
*/
public class GroupShape extends mxBasicShape {
public void paintShape(mxGraphics2DCanvas canvas, mxCellState state) {
Rectangle tmp = state.getRectangle();
int x = tmp.x;
int y = tmp.y;
int w = tmp.width;
int h = tmp.height;
int radius = getArcSize(w, h);
float opacity = mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_OPACITY, 0);
if (canvas.getGraphics().hitClip(x, y, w, h)) {
// Paints the background
if (configureGraphics(canvas, state, true)) {
canvas.getGraphics().setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity / 100));
canvas.getGraphics().fillRoundRect(x, y, w, h, radius, radius);
}
// Paints the foreground
if (configureGraphics(canvas, state, false)) {
canvas.getGraphics().setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
canvas.getGraphics().drawRoundRect(x, y, w, h, radius, radius);
}
}
}
public int getArcSize(int w, int h) {
return Constants.RECTANGLE_ARCSIZE + 7;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy