BufferedImage bi;
Rectangle2D rect;
+ float alpha;
- public AWTImage(BufferedImage bi) {
+ public AWTImage(BufferedImage bi, float alpha) {
assert(bi!=null);
this.bi = bi;
+ this.alpha = alpha;
rect = new Rectangle2D.Double(bi.getMinX(),bi.getMinY(),bi.getWidth(), bi.getHeight());
}
+
+ public AWTImage(BufferedImage bi) {
+ this(bi, 1.0f);
+ }
@Override
public Rectangle2D getBounds() {
public Node init(G2DParentNode parent) {
ImageNode node = parent.getOrCreateNode("image", ImageNode.class);
node.setImage(bi);
+ node.setAlpha(alpha);
+ node.setZIndex(-100);
return node;
}
*******************************************************************************/
package org.simantics.scenegraph.g2d.nodes;
+import java.awt.AlphaComposite;
+import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
protected Boolean visible = Boolean.TRUE;
protected BufferedImage img = null;
+ protected float alpha = 1.0f;
@SyncField("visible")
public void setVisible(Boolean visible) {
public void setImage(BufferedImage src) {
img = src;
}
+
+ public void setAlpha(float alpha) {
+ this.alpha = alpha;
+ }
@Override
public void render(Graphics2D g) {
// Rectangle2D b = parent.getBoundsInLocal();
// g.drawImage(img, (int)b.getMinX(), (int)b.getMinY(), (int)b.getWidth()+(int)b.getMinX(), (int)b.getHeight()+(int)b.getMinY(), 0, 0, img.getWidth(), img.getHeight(), null);
// }
+
+
+ Composite old = g.getComposite();
+ g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
+
g.drawImage(img, 0, 0, null);
+ if (old != null)
+ g.setComposite(old);
if (ot != null)
g.setTransform(ot);
}
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MArea;
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
EPartService partService = context.get(EPartService.class);
return partService.findPart(partId);
}
+
+ public static MCommand getMCommandById(String id) {
+ IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class);
+ MApplication application = context.get(MApplication.class);
+ for (MCommand command : application.getCommands()) {
+ if (id.equals(command.getElementId())) {
+ return command;
+ }
+ }
+ return null;
+ }
@SuppressWarnings("restriction")
public static IEditorPart getActiveIEditorPart(MPart mActiveEditorPart) {