Here you can find the source of drawBeamsplit(Graphics g, int midx, int midy, Color cup, Color cdown, Color cright, boolean showMirror, boolean isDichroic)
public static void drawBeamsplit(Graphics g, int midx, int midy, Color cup, Color cdown, Color cright, boolean showMirror, boolean isDichroic)
//package com.java2s; /***/*w w w. j a v a2 s . c o m*/ * Copyright (C) 2010 Johan Henriksson * This code is under the Endrov / BSD license. See www.endrov.net * for the full text and how to cite. */ import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; public class Main { private static final int beamR = 6; public static void drawBeamsplit(Graphics g, int midx, int midy, Color cup, Color cdown, Color cright, boolean showMirror, boolean isDichroic) { int boxR = 15; //Box g.setColor(Color.lightGray); g.fillRect(midx - boxR, midy - boxR, boxR * 2, boxR * 2); //g.drawRect(midx-boxR, midy-boxR, boxR*2, boxR*2); //Beams float[] carr = new float[3]; if (cright != null) { cright.getColorComponents(carr); for (int i = -beamR; i < beamR; i++) { float weight = fmin1((beamR - Math.abs(i)) / (double) beamR); g.setColor(new Color(carr[0], carr[1], carr[2], weight)); g.drawLine(midx - i, midy + i, midx + boxR, midy + i); } } if (cdown != null) { cdown.getColorComponents(carr); for (int i = -beamR; i < beamR; i++) { float weight = fmin1((beamR - Math.abs(i)) / (double) beamR); g.setColor(new Color(carr[0], carr[1], carr[2], weight)); g.drawLine(midx + i, midy - i, midx + i, midy + boxR); } } if (cup != null) { cup.getColorComponents(carr); for (int i = -beamR; i < beamR; i++) { float weight = fmin1((beamR - Math.abs(i)) / (double) beamR); g.setColor(new Color(carr[0], carr[1], carr[2], weight)); g.drawLine(midx + i, midy - boxR, midx + i, midy - i); } } //Mirror if (showMirror) { if (isDichroic) { float[] Dashes = { 3.0F, 3.0F }; g = g.create(); ((Graphics2D) g).setStroke( new BasicStroke(1.0F, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0F, Dashes, 0.F)); } g.setColor(Color.BLACK); g.drawLine(midx - boxR, midy + boxR, midx + boxR, midy - boxR); } } private static float fmin1(double x) { return Math.max(Math.min(0.9f, (float) x), 0f); } }