Changed border simulation ratio to fill the border

Former-commit-id: 2d7cfee11127d09c1a71d84dab2d03f3cf003013
This commit is contained in:
T. van der Zwan 2013-11-16 20:53:47 +01:00
parent 095e303443
commit 28f07ec739
2 changed files with 8 additions and 11 deletions

View File

@ -33,8 +33,6 @@ import org.hyperion.hypercon.spec.LedFrameConstruction;
public class LedSimulationComponent extends JPanel {
private double mBorderFraction = 0.2;
private BufferedImage mTvImage = new BufferedImage(640, 480, BufferedImage.TYPE_INT_ARGB);
private void setImage(Image pImage) {
@ -173,8 +171,8 @@ public class LedSimulationComponent extends JPanel {
}
int width = backgroundImage.getWidth();
int height = backgroundImage.getHeight();
int borderWidth = (int) (backgroundImage.getWidth() * mBorderFraction);
int borderHeight = (int) (backgroundImage.getHeight() * mBorderFraction);
int borderWidth = (int) (backgroundImage.getWidth() * 0.1);
int borderHeight = (int) (backgroundImage.getHeight() * 0.2);
mTopLeftImage.setImage(backgroundImage.getSubimage(0, 0, borderWidth, borderHeight));
mTopImage.setImage(backgroundImage.getSubimage(borderWidth, 0, width-2*borderWidth, borderHeight));

View File

@ -15,8 +15,6 @@ import org.hyperion.hypercon.spec.Led;
public class LedSimulationWorker extends SwingWorker<BufferedImage, Object> {
private final double mBorderFraction = 0.2;
private final BufferedImage mTvImage;
private final Vector<Led> mLeds;
@ -78,15 +76,16 @@ public class LedSimulationWorker extends SwingWorker<BufferedImage, Object> {
}
Point tv2image(Dimension pImageDim, Point2D point) {
double tvFraction = (1.0 - 2*mBorderFraction);
double tvWidthFraction = (1.0 - 2*0.1);
double tvHeightFraction = (1.0 - 2*0.2);
double tvWidth = tvFraction * pImageDim.width;
double tvWidth = tvWidthFraction * pImageDim.width;
double tvXIndex = point.getX()*tvWidth;
double imageXIndex = tvXIndex + mBorderFraction*pImageDim.width;
double imageXIndex = tvXIndex + 0.1*pImageDim.width;
double tvHeight = tvFraction * pImageDim.height;
double tvHeight = tvHeightFraction * pImageDim.height;
double tvYIndex = point.getY()*tvHeight;
double imageYIndex = tvYIndex + mBorderFraction*pImageDim.height;
double imageYIndex = tvYIndex + 0.2*pImageDim.height;
return new Point((int)imageXIndex, (int)imageYIndex);
}