forked from jgraph/mxgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmxImageShape.java
More file actions
80 lines (68 loc) · 1.69 KB
/
mxImageShape.java
File metadata and controls
80 lines (68 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* 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. See mxImageBundle for
* creating a lookup table with images which can then be referenced by key.
*/
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);
}
}