Add inverted color mode and Confirmation message to Framebufferizer.

This patch allows specifying the confirmation message and the inverted
colors flag in the user interface. It also slightly improves the
configuration page layout of the Framebufferizer tool.

Test: LD_LIBRARY_PATH=./out/host/linux-x86/lib64 TeeuiFramebufferizer
Change-Id: Ieea6f7c4cf90291edb749cf0f55ba5385d93c64e
diff --git a/libteeui/example/teeui.cpp b/libteeui/example/teeui.cpp
index 1ee7718..9b9ed57 100644
--- a/libteeui/example/teeui.cpp
+++ b/libteeui/example/teeui.cpp
@@ -25,6 +25,22 @@
 
 static DeviceInfo sDeviceInfo;
 static bool sMagnified;
+static bool sInverted;
+static std::string sConfirmationMessage;
+
+/*
+ * AOSP color scheme constants.
+ */
+constexpr static const Color kShieldColor = Color(0xff778500);
+constexpr static const Color kShieldColorInv = Color(0xffc4cb80);
+constexpr static const Color kTextColor = Color(0xff212121);
+constexpr static const Color kTextColorInv = Color(0xffdedede);
+constexpr static const Color kBackGroundColor = Color(0xffffffff);
+constexpr static const Color kBackGroundColorInv = Color(0xff212121);
+
+void setConfirmationMessage(const char* confirmationMessage) {
+    sConfirmationMessage = confirmationMessage;
+}
 
 uint32_t alfaCombineChannel(uint32_t shift, double alfa, uint32_t a, uint32_t b) {
     a >>= shift;
@@ -75,9 +91,10 @@
     return (std::get<Elements>(layout).draw(drawPixel) || ...);
 }
 
-uint32_t setDeviceInfo(DeviceInfo deviceInfo, bool magnified) {
+uint32_t setDeviceInfo(DeviceInfo deviceInfo, bool magnified, bool inverted) {
     sDeviceInfo = deviceInfo;
     sMagnified = magnified;
+    sInverted = inverted;
     return 0;
 }
 
@@ -109,30 +126,42 @@
         afterLastPixelIndex > buffer_size_in_elements_not_bytes) {
         return uint32_t(Error::OutOfBoundsDrawing);
     }
-    context<ConUIParameters> conv(sDeviceInfo.mm2px_, sDeviceInfo.dp2px_);
-    conv.setParam<RightEdgeOfScreen>(pxs(sDeviceInfo.width_));
-    conv.setParam<BottomOfScreen>(pxs(sDeviceInfo.height_));
-    conv.setParam<PowerButtonTop>(mms(sDeviceInfo.powerButtonTopMm_));
-    conv.setParam<PowerButtonBottom>(mms(sDeviceInfo.powerButtonBottomMm_));
-    conv.setParam<VolUpButtonTop>(mms(sDeviceInfo.volUpButtonTopMm_));
-    conv.setParam<VolUpButtonBottom>(mms(sDeviceInfo.volUpButtonBottomMm_));
+    context<ConUIParameters> ctx(sDeviceInfo.mm2px_, sDeviceInfo.dp2px_);
+    ctx.setParam<RightEdgeOfScreen>(pxs(sDeviceInfo.width_));
+    ctx.setParam<BottomOfScreen>(pxs(sDeviceInfo.height_));
+    ctx.setParam<PowerButtonTop>(mms(sDeviceInfo.powerButtonTopMm_));
+    ctx.setParam<PowerButtonBottom>(mms(sDeviceInfo.powerButtonBottomMm_));
+    ctx.setParam<VolUpButtonTop>(mms(sDeviceInfo.volUpButtonTopMm_));
+    ctx.setParam<VolUpButtonBottom>(mms(sDeviceInfo.volUpButtonBottomMm_));
     if (sMagnified) {
-        conv.setParam<DefaultFontSize>(18_dp);
-        conv.setParam<BodyFontSize>(20_dp);
+        ctx.setParam<DefaultFontSize>(18_dp);
+        ctx.setParam<BodyFontSize>(20_dp);
     } else {
-        conv.setParam<DefaultFontSize>(14_dp);
-        conv.setParam<BodyFontSize>(16_dp);
+        ctx.setParam<DefaultFontSize>(14_dp);
+        ctx.setParam<BodyFontSize>(16_dp);
     }
 
-    auto layoutInstance = instantiateLayout(ConfUILayout(), conv);
+    if (sInverted) {
+        ctx.setParam<ShieldColor>(kShieldColorInv);
+        ctx.setParam<ColorText>(kTextColorInv);
+        ctx.setParam<ColorBG>(kBackGroundColorInv);
+    } else {
+        ctx.setParam<ShieldColor>(kShieldColor);
+        ctx.setParam<ColorText>(kTextColor);
+        ctx.setParam<ColorBG>(kBackGroundColor);
+    }
+
+    auto layoutInstance = instantiateLayout(ConfUILayout(), ctx);
 
     translateLabels(layoutInstance);
 
     uint32_t* begin = buffer + (y * lineStride + x);
+
+    Color bgColor = sInverted ? kBackGroundColorInv : kBackGroundColor;
+
     for (uint32_t yi = 0; yi < h; ++yi) {
         for (uint32_t xi = 0; xi < w; ++xi) {
-            begin[xi] = 0xffffffff;
-            //            begin[xi] = renderPixel(x + xi, y + yi, layoutInstance);
+            begin[xi] = bgColor;
         }
         begin += lineStride;
     }
@@ -148,6 +177,9 @@
     auto pixelDrawer = makePixelDrawer(
         [&fb](uint32_t x, uint32_t y, Color color) -> Error { return fb.drawPixel(x, y, color); });
 
+    std::get<LabelBody>(layoutInstance)
+        .setText({&*sConfirmationMessage.begin(), &*sConfirmationMessage.end()});
+
     if (auto error = drawElements(layoutInstance, pixelDrawer)) {
         return uint32_t(error.code());
     }
diff --git a/libteeui/include/teeui/example/teeui.h b/libteeui/include/teeui/example/teeui.h
index 2e456e7..3ee37f4 100644
--- a/libteeui/include/teeui/example/teeui.h
+++ b/libteeui/include/teeui/example/teeui.h
@@ -32,10 +32,12 @@
     double volUpButtonBottomMm_;
 };
 
-uint32_t setDeviceInfo(DeviceInfo device_info, bool magnified);
+uint32_t setDeviceInfo(DeviceInfo device_info, bool magnified, bool inverted = false);
 uint32_t renderUIIntoBuffer(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t lineStride,
                             uint32_t* buffer, size_t buffer_size_in_elements_not_bytes);
 
 void selectLanguage(const char* language_id);
 
+void setConfirmationMessage(const char* confirmationMessage);
+
 #endif  // TEEUI_LIBTEEUI_INCLUDE_TEEUI_H_
diff --git a/libteeui_jni/include/com_android_framebufferizer_NativeRenderer.h b/libteeui_jni/include/com_android_framebufferizer_NativeRenderer.h
index 774200c..10b10a8 100644
--- a/libteeui_jni/include/com_android_framebufferizer_NativeRenderer.h
+++ b/libteeui_jni/include/com_android_framebufferizer_NativeRenderer.h
@@ -10,12 +10,10 @@
 /*
  * Class:     com_android_framebufferizer_NativeRenderer
  * Method:    setDeviceInfo
- * Signature: (Lcom/android/framebufferizer/utils/DeviceInfo;Z)I
+ * Signature: (Lcom/android/framebufferizer/utils/DeviceInfo;ZZ)I
  */
-JNIEXPORT jint JNICALL Java_com_android_framebufferizer_NativeRenderer_setDeviceInfo(JNIEnv*,
-                                                                                     jclass,
-                                                                                     jobject,
-                                                                                     jboolean);
+JNIEXPORT jint JNICALL Java_com_android_framebufferizer_NativeRenderer_setDeviceInfo(
+    JNIEnv*, jclass, jobject, jboolean, jboolean);
 
 /*
  * Class:     com_android_framebufferizer_NativeRenderer
@@ -26,19 +24,29 @@
     JNIEnv*, jclass, jint, jint, jint, jint, jint, jintArray);
 
 /*
- * Class:     com_android_framebufferizer_NativeRenderer_setLanguage
+ * Class:     com_android_framebufferizer_NativeRenderer
  * Method:    setLanguage
- * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ * Signature: (Ljava/lang/String;)V
  */
 JNIEXPORT void JNICALL Java_com_android_framebufferizer_NativeRenderer_setLanguage(JNIEnv*, jclass,
                                                                                    jstring);
+
 /*
- * Class:     com_android_framebufferizer_NativeRenderer_getLanguageIdList
+ * Class:     com_android_framebufferizer_NativeRenderer
  * Method:    getLanguageIdList
+ * Signature: ()[Ljava/lang/String;
  */
 JNIEXPORT jobjectArray JNICALL
 Java_com_android_framebufferizer_NativeRenderer_getLanguageIdList(JNIEnv*, jclass);
 
+/*
+ * Class:     com_android_framebufferizer_NativeRenderer
+ * Method:    setConfimationMessage
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL
+Java_com_android_framebufferizer_NativeRenderer_setConfimationMessage(JNIEnv*, jclass, jstring);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/libteeui_jni/libteeui_jni.cpp b/libteeui_jni/libteeui_jni.cpp
index ee08859..807100e 100644
--- a/libteeui_jni/libteeui_jni.cpp
+++ b/libteeui_jni/libteeui_jni.cpp
@@ -126,10 +126,10 @@
 /*
  * Class:     com_android_framebufferizer_NativeRenderer
  * Method:    setDeviceInfo
- * Signature: (Lcom/android/framebufferizer/utils/DeviceInfo;Z)I
+ * Signature: (Lcom/android/framebufferizer/utils/DeviceInfo;ZZ)I
  */
 extern "C" JNIEXPORT jint JNICALL Java_com_android_framebufferizer_NativeRenderer_setDeviceInfo(
-    JNIEnv* env, jclass, jobject jDeviceInfo, jboolean magnified) {
+    JNIEnv* env, jclass, jobject jDeviceInfo, jboolean magnified, jboolean inverted) {
     jclass cDeviceInfo = env->FindClass("Lcom/android/framebufferizer/utils/DeviceInfo;");
     jmethodID method = env->GetMethodID(cDeviceInfo, "getWidthPx", "()I");
     DeviceInfo device_info;
@@ -148,7 +148,7 @@
     device_info.volUpButtonTopMm_ = env->CallDoubleMethod(jDeviceInfo, method);
     method = env->GetMethodID(cDeviceInfo, "getVolUpButtonBottomMm", "()D");
     device_info.volUpButtonBottomMm_ = env->CallDoubleMethod(jDeviceInfo, method);
-    return setDeviceInfo(device_info, magnified);
+    return setDeviceInfo(device_info, magnified, inverted);
 }
 
 /*
@@ -165,8 +165,9 @@
                               (uint32_t)lineStride, (uint32_t*)buffer.begin(), buffer.size());
 }
 /*
- * Class:     com_android_framebufferizer_NativeRenderer_setLanguage
- * Method:    setLanguage
+ * Class:     com_android_confirmationui_Translation_selectLangID
+ * Method:    selectLangID
+ * Signature: (Ljava/lang/String;)V
  */
 extern "C" JNIEXPORT void JNICALL
 Java_com_android_framebufferizer_NativeRenderer_setLanguage(JNIEnv* env, jclass, jstring jlang_id) {
@@ -176,8 +177,9 @@
     (env)->ReleaseStringUTFChars(jlang_id, lang_id);
 }
 /*
- * Class:     com_android_framebufferizer_NativeRenderer_getLanguageIdList
- * Method:    getLanguageIdList
+ * Class:     com_android_confirmationui_Translation_selectLangID
+ * Method:    selectLangID
+ * Signature: ()[Ljava/lang/String;
  */
 extern "C" JNIEXPORT jobjectArray JNICALL
 Java_com_android_framebufferizer_NativeRenderer_getLanguageIdList(JNIEnv* env, jclass) {
@@ -194,3 +196,14 @@
 
     return language_ids;
 }
+/*
+ * Class:     com_android_framebufferizer_NativeRenderer
+ * Method:    setConfimationMessage
+ * Signature: (Ljava/lang/String;)V
+ */
+extern "C" JNIEXPORT void JNICALL
+Java_com_android_framebufferizer_NativeRenderer_setConfimationMessage(
+    JNIEnv* env, jclass, jstring jConfirmationMessage) {
+    JString confirmationMessage(env, jConfirmationMessage);
+    setConfirmationMessage(confirmationMessage.begin());
+}
diff --git a/tools/framebufferizer/src/com/android/framebufferizer/Main.java b/tools/framebufferizer/src/com/android/framebufferizer/Main.java
index 8bd76dd..b4b938f 100644
--- a/tools/framebufferizer/src/com/android/framebufferizer/Main.java
+++ b/tools/framebufferizer/src/com/android/framebufferizer/Main.java
@@ -20,8 +20,6 @@
 import com.android.framebufferizer.utils.FrameBufferBuffer;
 
 import java.awt.*;
-import java.awt.image.DataBufferInt;
-import java.security.SecureRandom;
 import java.util.Random;
 
 import javax.swing.*;
@@ -37,19 +35,15 @@
         theFramebuffer = new FrameBufferBuffer();
         theFramebuffer.setFrame(theFrame);
         FrameBufferBuffer.MagnifiedView magnifiedView = theFramebuffer.getMagnifiedView();
-        FrameBufferBuffer.DeviceSelector deviceSelector = theFramebuffer.getDeviceSelector();
-        FrameBufferBuffer.LanguageSelector languageSelector = theFramebuffer.getLanguageSelector();
+        FrameBufferBuffer.ConfigSelector configSelector = theFramebuffer.getConfigSelector();
         magnifiedView.setPreferredSize(new Dimension(100, 100));
         magnifiedView.setMinimumSize(new Dimension(100, 100));
         magnifiedView.setMaximumSize(new Dimension(100, 100));
         theFrame.getContentPane().add(magnifiedView, BorderLayout.EAST);
         theFrame.getContentPane().add(theFramebuffer, BorderLayout.CENTER);
-        theFrame.getContentPane().add(deviceSelector, BorderLayout.NORTH);
-        theFrame.getContentPane().add(languageSelector, BorderLayout.SOUTH);
+        theFrame.getContentPane().add(configSelector, BorderLayout.NORTH);
         theFrame.pack();
         theFrame.setVisible(true);
-        deviceSelector.refreshSelections();
-
     }
 
     public static void main(String[] args) {
diff --git a/tools/framebufferizer/src/com/android/framebufferizer/NativeRenderer.java b/tools/framebufferizer/src/com/android/framebufferizer/NativeRenderer.java
index 0198892..eca320e 100644
--- a/tools/framebufferizer/src/com/android/framebufferizer/NativeRenderer.java
+++ b/tools/framebufferizer/src/com/android/framebufferizer/NativeRenderer.java
@@ -23,8 +23,9 @@
          System.loadLibrary("teeui_jni");
     }
 
-    public static native int setDeviceInfo(DeviceInfo deviceInfo, boolean magnified);
+    public static native int setDeviceInfo(DeviceInfo deviceInfo, boolean magnified, boolean inverted);
     public static native int renderBuffer(int x, int y, int width, int height, int lineStride, int[] buffer);
     public static native void setLanguage(String language_id);
     public static native String[] getLanguageIdList();
+    public static native void setConfimationMessage(String confimationMessage);
 }
diff --git a/tools/framebufferizer/src/com/android/framebufferizer/utils/FrameBufferBuffer.java b/tools/framebufferizer/src/com/android/framebufferizer/utils/FrameBufferBuffer.java
index a1104f1..4b97657 100644
--- a/tools/framebufferizer/src/com/android/framebufferizer/utils/FrameBufferBuffer.java
+++ b/tools/framebufferizer/src/com/android/framebufferizer/utils/FrameBufferBuffer.java
@@ -23,8 +23,6 @@
 import java.awt.event.ComponentListener;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseMotionListener;
-import java.awt.event.ItemListener;
-import java.awt.event.ItemEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
 import java.awt.geom.AffineTransform;
@@ -88,63 +86,112 @@
     }
 
 
-    public class DeviceSelector extends JPanel implements ActionListener {
-        private JComboBox<String> dropDownMenu = new JComboBox(DeviceInfoDB.Device.values());
-        private JCheckBox magnifiedCheckbox = new JCheckBox("Magnified");
+    public class ConfigSelector extends JPanel implements ActionListener {
+        private final String languages [];
 
-        protected DeviceSelector() {
-            dropDownMenu.addActionListener(this);
+        {
+            languages = NativeRenderer.getLanguageIdList();
+        }
+
+        private JComboBox<String> deviceSelector = new JComboBox(DeviceInfoDB.Device.values());
+        private JCheckBox magnifiedCheckbox = new JCheckBox("Magnified");
+        private JCheckBox invertedCheckbox = new JCheckBox("Inverted");
+        private JComboBox<String> localeSelector = new JComboBox(languages);
+        private JTextField confirmationMessage = new JTextField();
+
+        protected ConfigSelector() {
+            System.err.println("ConfigSelector");
+            this.setLayout(new GridBagLayout());
+
+            GridBagConstraints c = null;
+
+            c = new GridBagConstraints();
+            c.gridx = 0;
+            c.gridy = 0;
+            this.add(new JLabel("Select Device:"), c);
+
+            deviceSelector.addActionListener(this);
+            c = new GridBagConstraints();
+            c.gridx = 1;
+            c.gridy = 0;
+            c.fill = GridBagConstraints.HORIZONTAL;
+            c.gridwidth = 2;
+            this.add(deviceSelector, c);
+
+            c = new GridBagConstraints();
+            c.gridx = 0;
+            c.gridy = 1;
+            this.add(new JLabel("Select Locale:"), c);
+
+            localeSelector.addActionListener(this);
+            c = new GridBagConstraints();
+            c.gridx = 1;
+            c.gridy = 1;
+            c.gridwidth = 2;
+            c.fill = GridBagConstraints.HORIZONTAL;
+            this.add(localeSelector, c);
+
+            c = new GridBagConstraints();
+            c.gridx = 0;
+            c.gridy = 2;
+            this.add(new JLabel("UIOptions:"), c);
+
             magnifiedCheckbox.addActionListener(this);
-            this.add(dropDownMenu);
-            this.add(magnifiedCheckbox);
+            c = new GridBagConstraints();
+            c.gridx = 1;
+            c.gridy = 2;
+            this.add(magnifiedCheckbox, c);
+
+            invertedCheckbox.addActionListener(this);
+            c = new GridBagConstraints();
+            c.gridx = 2;
+            c.gridy = 2;
+            this.add(invertedCheckbox, c);
+
+            c = new GridBagConstraints();
+            c.gridx = 0;
+            c.gridy = 3;
+            this.add(new JLabel("Confirmation message:"), c);
+
+            confirmationMessage.setText("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
+            confirmationMessage.addActionListener(this);
+            c = new GridBagConstraints();
+            c.gridx = 1;
+            c.gridy = 3;
+            c.fill = GridBagConstraints.BOTH;
+            c.gridwidth = 2;
+            this.add(confirmationMessage, c);
         }
 
         public void actionPerformed(ActionEvent e) {
-            synchronized (this) {
-                FrameBufferBuffer.this.calibrateNativeBuffer();
-            }
-        }
-
-        public void refreshSelections(){
-            dropDownMenu.setSelectedItem(DeviceInfoDB.Device.CORAL);
+            FrameBufferBuffer.this.renderNativeBuffer();
         }
 
         public DeviceInfoDB.Device currentDevice() {
-            return (DeviceInfoDB.Device) dropDownMenu.getSelectedItem();
+            return (DeviceInfoDB.Device) deviceSelector.getSelectedItem();
+        }
+
+        public String currentLocale() {
+            return (String)localeSelector.getSelectedItem();
         }
 
         public boolean magnified() {
             return magnifiedCheckbox.isSelected();
         }
-    }
 
-    public class LanguageSelector extends JPanel implements ActionListener {
-        String languages [] = NativeRenderer.getLanguageIdList();
-
-        private JComboBox<String> dropDownMenu;
-
-        protected LanguageSelector() {
-            dropDownMenu = new JComboBox(languages);
-            dropDownMenu.addActionListener(this);
-            this.add(dropDownMenu);
+        public boolean inverted() {
+            return invertedCheckbox.isSelected();
         }
 
-        public void actionPerformed(ActionEvent e) {
-            synchronized (this) {
-                String language = (String) dropDownMenu.getSelectedItem();
-                NativeRenderer.setLanguage(language);
-                FrameBufferBuffer.this.calibrateNativeBuffer();
-            }
+        public String confirmationMessage() {
+            return confirmationMessage.getText();
         }
-
     }
 
-
     private BufferedImage mImage;
     private DataBufferInt mBuffer;
     private MagnifiedView mMagnifiedView;
-    private DeviceSelector mDeviceSelector;
-    private LanguageSelector mLanguageSelector;
+    private ConfigSelector mConfigSelector;
     private JFrame mFrame;
 
     public MagnifiedView getMagnifiedView() {
@@ -154,18 +201,11 @@
         return mMagnifiedView;
     }
 
-    public DeviceSelector getDeviceSelector(){
-        if (mDeviceSelector == null){
-            mDeviceSelector = new DeviceSelector();
+    public ConfigSelector getConfigSelector(){
+        if (mConfigSelector == null){
+            mConfigSelector = new ConfigSelector();
         }
-        return mDeviceSelector;
-    }
-
-    public LanguageSelector getLanguageSelector(){
-        if (mLanguageSelector == null){
-            mLanguageSelector = new LanguageSelector();
-        }
-        return mLanguageSelector;
+        return mConfigSelector;
     }
 
     @Override
@@ -205,14 +245,14 @@
     public FrameBufferBuffer() {
         setSize(412, 900);
         setPreferredSize(new Dimension(412, 900));
-        calibrateNativeBuffer();
+        renderNativeBuffer();
         addComponentListener(this);
         addMouseMotionListener(this);
     }
 
     @Override
     public void componentResized(ComponentEvent e) {
-        calibrateNativeBuffer();
+        renderNativeBuffer();
         repaint();
     }
     @Override
@@ -241,13 +281,12 @@
         mFrame = frame;
     }
 
-    public void calibrateNativeBuffer(){
-      DeviceInfo deviceInfo = DeviceInfoDB.getDeviceInfo(getDeviceSelector().currentDevice());
-      boolean magnified = getDeviceSelector().magnified();
-      renderNativeBuffer(deviceInfo, magnified);
-      repaint();
-    }
-    public int renderNativeBuffer(DeviceInfo deviceInfo, boolean magnified){
+    public void renderNativeBuffer(){
+        DeviceInfo deviceInfo = DeviceInfoDB.getDeviceInfo(getConfigSelector().currentDevice());
+        boolean magnified = getConfigSelector().magnified();
+        boolean inverted = getConfigSelector().inverted();
+        NativeRenderer.setLanguage(getConfigSelector().currentLocale());
+        NativeRenderer.setConfimationMessage(getConfigSelector().confirmationMessage());
         int w = deviceInfo.getWidthPx();
         int h = deviceInfo.getHeightPx();
         final int linestride = w;
@@ -262,7 +301,7 @@
                 new int[]{rMask, gMask, bMask}, null);
             ColorModel colorModel = new DirectColorModel(bpp, rMask, gMask, bMask);
             BufferedImage image = new BufferedImage(colorModel, raster, true, null);
-            NativeRenderer.setDeviceInfo(deviceInfo, magnified);
+            NativeRenderer.setDeviceInfo(deviceInfo, magnified, inverted);
             error = NativeRenderer.renderBuffer(0, 0, w, h, linestride, mBuffer.getData());
             if (error != 0) {
                 System.out.println("Error rendering native buffer " + error);
@@ -270,12 +309,17 @@
 
             mImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
             Graphics2D gc = mImage.createGraphics();
-            double scale = (double)getWidth()/(double)w;
+            double scale = 0.0;
+            if (w/(double)h > getWidth()/(double)getHeight()) {
+                scale = (double)getWidth()/(double)w;
+            } else {
+                scale = (double)getHeight()/(double)h;
+            }
             gc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
             gc.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
             gc.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
             gc.drawRenderedImage(image, AffineTransform.getScaleInstance(scale, scale));
         }
-        return error;
+        repaint();
     }
 }