This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final Comparator<Function> IDENTITY = (left, right) -> | |
Integer.compare(left.getId(), right.getId()); | |
public static final Comparator<Transform> Z_ORDER = (left, right) -> | |
ComparisonChain.start() | |
.compare(left.getZIndex(), right.getZIndex()) | |
.compare(left, right, IDENTITY) | |
.result(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void save(IFS ifs, File file) { | |
try (FileWriter writer = new FileWriter(file)) { | |
JAXBContext context = JAXBContext.newInstance(IFS.class); | |
Marshaller marshaller = context.createMarshaller(); | |
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); | |
marshaller.marshal(ifs, writer); | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@XmlAttribute | |
private String name; | |
@XmlElementWrapper(name = "Transforms") | |
@XmlElement(name = "Transform") | |
private List<Transform> transforms = Lists.newLinkedList(); | |
@XmlElementWrapper(name = "Reflections") | |
@XmlElement(name = "Reflection") | |
private List<Reflection> reflections = Lists.newLinkedList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GestureUtilities.addGestureListenerTo(controller.getEditor(), new RotationListener() { | |
@Override | |
public void rotate(RotationEvent re) { | |
if (controller.getEditor().isVisible()) { | |
Transform selected = controller.getEditor().getSelected(); | |
if (selected != null && !selected.isMatrix()) { | |
selected.r -= Math.toRadians(re.getRotation()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pauseViewer(() -> { | |
PrinterJob job = PrinterJob.getPrinterJob(); | |
job.setJobName(Optional.fromNullable(ifs.getName()).or(IFS.UNTITLED)); | |
PageFormat pf = job.defaultPage(); | |
if (getWidth() > getHeight()) { | |
pf.setOrientation(PageFormat.LANDSCAPE); | |
} else { | |
pf.setOrientation(PageFormat.PORTRAIT); | |
} | |
switch (current) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setEditable(false); | |
setContentType(HTML_MIME_TYPE); | |
setText(INITIAL_CONTENT_HTML); | |
HTMLEditorKit kit = (HTMLEditorKit) getEditorKitForContentType(HTML_MIME_TYPE); | |
StyleSheet css = kit.getStyleSheet(); | |
for (String rule : Iterables.concat(CSS_RULES, CSS_BRACKET_RULES)) { | |
css.addRule(rule); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Print splash screen text | |
SplashScreen splash = SplashScreen.getSplashScreen(); | |
if (splash != null && splash.isVisible()) { | |
context(printError(), splash.createGraphics(), g -> { | |
About.paintSplashText(g, splash.getSize().width, splash.getSize().height); | |
splash.update(); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context(exceptionHandler, image.getGraphics(), g -> { | |
g.setColor(config.getRender().getBackground()); | |
g.fillRect(0, 0, size.width, size.height); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch (corner) { | |
case NW: | |
x += (inverseX.x + inverseY.x); | |
y += (inverseX.y + inverseY.y); | |
w -= delta.x; | |
h -= delta.y; | |
break; | |
case NE: | |
x += inverseY.x; | |
y += inverseY.y; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Corner getCorner(Transform t, Point point) { | |
for (Corner corner : Corner.values()) { | |
Point center = corner.getPoint(unit()); | |
t.getTransform().transform(center, center); | |
Rectangle handle = new Rectangle(center.x — 5, center.y — 5, 10, 10); | |
if (handle.contains(point)) { | |
return corner; | |
} | |
} | |
return null; |