com.mxgraph.shape.mxImageShape Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jgraphx Show documentation
Show all versions of jgraphx Show documentation
JGraphX Swing Component - Java Graph Visualization Library
This is a binary & source redistribution of the original, unmodified JGraphX library originating from:
"https://github.com/jgraph/jgraphx/archive/v3.4.1.3.zip".
The purpose of this redistribution is to make the library available to other Maven projects.
/**
* $Id: mxImageShape.java,v 1.6 2011/01/05 11:20:51 gaudenz Exp $
* Copyright (c) 2007-2010, Gaudenz Alder, David Benson
*/
package com.mxgraph.shape;
import java.awt.Color;
import java.awt.Rectangle;
import com.mxgraph.canvas.mxGraphics2DCanvas;
import com.mxgraph.util.mxConstants;
import com.mxgraph.util.mxUtils;
import com.mxgraph.view.mxCellState;
/**
* A rectangular shape that contains a single image
*/
public class mxImageShape extends mxRectangleShape
{
/**
*
*/
public void paintShape(mxGraphics2DCanvas canvas, mxCellState state)
{
super.paintShape(canvas, state);
boolean flipH = mxUtils.isTrue(state.getStyle(),
mxConstants.STYLE_IMAGE_FLIPH, false);
boolean flipV = mxUtils.isTrue(state.getStyle(),
mxConstants.STYLE_IMAGE_FLIPV, false);
canvas.drawImage(getImageBounds(canvas, state),
getImageForStyle(canvas, state),
mxGraphics2DCanvas.PRESERVE_IMAGE_ASPECT, flipH, flipV);
}
/**
*
*/
public Rectangle getImageBounds(mxGraphics2DCanvas canvas, mxCellState state)
{
return state.getRectangle();
}
/**
*
*/
public boolean hasGradient(mxGraphics2DCanvas canvas, mxCellState state)
{
return false;
}
/**
*
*/
public String getImageForStyle(mxGraphics2DCanvas canvas, mxCellState state)
{
return canvas.getImageForStyle(state.getStyle());
}
/**
*
*/
public Color getFillColor(mxGraphics2DCanvas canvas, mxCellState state)
{
return mxUtils.getColor(state.getStyle(),
mxConstants.STYLE_IMAGE_BACKGROUND);
}
/**
*
*/
public Color getStrokeColor(mxGraphics2DCanvas canvas, mxCellState state)
{
return mxUtils.getColor(state.getStyle(),
mxConstants.STYLE_IMAGE_BORDER);
}
}