|
|
|
@ -53,6 +53,7 @@ import java.io.File;
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.net.URI; |
|
|
|
|
import java.net.URISyntaxException; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author Starryi |
|
|
|
@ -79,10 +80,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
|
|
|
|
|
private NinePointImageTweakDialogPane tweakPane; |
|
|
|
|
private ImageFileChooser imageFileChooser; |
|
|
|
|
|
|
|
|
|
private int ninePointLeft = -1; |
|
|
|
|
private int ninePointTop = -1; |
|
|
|
|
private int ninePointRight = -1; |
|
|
|
|
private int ninePointBottom = -1; |
|
|
|
|
private int[] ninePoint = new int[] {-1, -1, -1, -1}; |
|
|
|
|
|
|
|
|
|
public BorderLineAndImagePane() { |
|
|
|
|
this.initComponents(); |
|
|
|
@ -242,8 +240,9 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
|
|
|
|
|
@Override |
|
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
|
Image image = imagePreviewPane.getImage(); |
|
|
|
|
ninePointLeft = ninePointRight = (image != null ? image.getWidth(null) / 3 : -1); |
|
|
|
|
ninePointTop = ninePointBottom = (image != null ? image.getHeight(null) / 3 : -1); |
|
|
|
|
ninePoint = new int[4]; |
|
|
|
|
ninePoint[0] = ninePoint[2] = (image != null ? image.getWidth(null) / 3 : -1); |
|
|
|
|
ninePoint[1] = ninePoint[3] = (image != null ? image.getHeight(null) / 3 : -1); |
|
|
|
|
borderImageOpacityPane.populateBean(1.0); |
|
|
|
|
if (image != null) { |
|
|
|
|
tweakNinePointButton.setEnabled(true); |
|
|
|
@ -260,10 +259,12 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
|
|
|
|
|
initNinePointTweakPaneIfNotExist(); |
|
|
|
|
|
|
|
|
|
if (imagePreviewPane.getImage() != null) { |
|
|
|
|
tweakPane.previewPane.setNinePoint(ninePoint); |
|
|
|
|
BasicDialog dialog = tweakPane.showWindow(SwingUtilities.getWindowAncestor(BorderLineAndImagePane.this)); |
|
|
|
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void doOk() { |
|
|
|
|
ninePoint = Arrays.copyOf(tweakPane.previewPane.getNinePoint(), 4); |
|
|
|
|
fireStateChanged(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -292,13 +293,11 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
|
|
|
|
|
this.tweakNinePointButton.setEnabled(true); |
|
|
|
|
this.borderImageOpacityPane.populateBean(style.getBorderImageOpacity()); |
|
|
|
|
if (ninePoint != null && ninePoint.length == 4 && ninePoint[0] > 0 && ninePoint[1] > 0 && ninePoint[2] > 0 && ninePoint[3] > 0) { |
|
|
|
|
ninePointLeft = ninePoint[0]; |
|
|
|
|
ninePointTop = ninePoint[1]; |
|
|
|
|
ninePointRight = ninePoint[2]; |
|
|
|
|
ninePointBottom = ninePoint[3]; |
|
|
|
|
this.ninePoint = Arrays.copyOf(ninePoint, 4); |
|
|
|
|
} else { |
|
|
|
|
ninePointLeft = ninePointRight = image.getWidth(null) / 3; |
|
|
|
|
ninePointTop = ninePointBottom = image.getHeight(null) / 3; |
|
|
|
|
this.ninePoint = new int[4]; |
|
|
|
|
this.ninePoint[0] = this.ninePoint[2] = image.getWidth(null) / 3; |
|
|
|
|
this.ninePoint[1] = this.ninePoint[3] = image.getHeight(null) / 3; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getComponent(1).setVisible(false); |
|
|
|
@ -331,7 +330,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
|
|
|
|
|
Image image = this.imagePreviewPane.getImage(); |
|
|
|
|
if (image != null) { |
|
|
|
|
ImageBackground newImageBackground = new ImageFileBackground(this.imagePreviewPane.getImageWithSuffix(), Constants.IMAGE_EXTEND); |
|
|
|
|
newImageBackground.setNinePoint(new int[] { ninePointLeft, ninePointTop, ninePointRight, ninePointBottom }); |
|
|
|
|
newImageBackground.setNinePoint(Arrays.copyOf(ninePoint, 4)); |
|
|
|
|
style.setBorderImage(newImageBackground); |
|
|
|
|
style.setBorderImageOpacity((float)borderImageOpacityPane.updateBean()); |
|
|
|
|
} |
|
|
|
@ -408,7 +407,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private class NinePointImageTweakDialogPane extends BasicPane { |
|
|
|
|
private final NinePointLinePreviewPane previewPane = new NinePointLinePreviewPane(); |
|
|
|
|
public final NinePointLinePreviewPane previewPane = new NinePointLinePreviewPane(); |
|
|
|
|
|
|
|
|
|
public NinePointImageTweakDialogPane() { |
|
|
|
|
this.initComponents(); |
|
|
|
@ -444,6 +443,11 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
|
|
|
|
|
public final Color TEXT_COLOR = Color.WHITE; |
|
|
|
|
public final int PADDING = 15; |
|
|
|
|
|
|
|
|
|
private int ninePointLeft = -1; |
|
|
|
|
private int ninePointTop = -1; |
|
|
|
|
private int ninePointRight = -1; |
|
|
|
|
private int ninePointBottom = -1; |
|
|
|
|
|
|
|
|
|
private int imgWidth; |
|
|
|
|
private int imgHeight; |
|
|
|
|
private int scaleImgWidth; |
|
|
|
@ -629,5 +633,17 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
|
|
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setNinePoint(int[] ninePoint) { |
|
|
|
|
ninePointLeft = ninePoint[0]; |
|
|
|
|
ninePointTop = ninePoint[1]; |
|
|
|
|
ninePointRight = ninePoint[2]; |
|
|
|
|
ninePointBottom = ninePoint[3]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int[] getNinePoint() { |
|
|
|
|
return new int[] { ninePointLeft, ninePointTop, ninePointRight, ninePointBottom }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|