// Chromis POS - The New Face of Open Source POS
// Copyright (c) (c) 2015-2016
// http://www.chromis.co.uk
//
// This file is part of Chromis POS
//
// Chromis POS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Chromis POS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Chromis POS. If not, see <http://www.gnu.org/licenses/>.
package uk.chromis.pos.printer.screen;
import uk.chromis.pos.forms.AppLocal;
import uk.chromis.pos.printer.DeviceDisplay;
import uk.chromis.pos.printer.DeviceDisplayAdvance;
import uk.chromis.pos.sales.JTicketLines;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import uk.chromis.pos.forms.JRootApp;
import uk.chromis.pos.scale.ScaleException;
/**
*
* @author adrian
*/
public class DeviceDisplayWindow extends javax.swing.JFrame implements DeviceDisplay, DeviceDisplayAdvance {
private final String m_sName;
private final DeviceDisplayPanel m_display;
/**
* Creates new form DeviceDisplayScreen
*/
public DeviceDisplayWindow() {
initComponents();
m_sName = AppLocal.getIntString("Display.Window");
m_display = new DeviceDisplayPanel(3.0);
m_jContainer.add(m_display.getDisplayComponent());
try {
JRootApp.m_Scale.readWeight();
} catch (ScaleException ex) {
Logger.getLogger(DeviceDisplayWindow.class.getName()).log(Level.SEVERE, null, ex);
}
setVisible(true);
}
/**
*
* @return
*/
@Override
public String getDisplayName() {
return m_sName;
}
/**
*
* @return
*/
@Override
public String getDisplayDescription() {
return null;
}
/**
*
* @return
*/
@Override
public JComponent getDisplayComponent() {
return null;
}
/**
*
* @param animation
* @param sLine1
* @param sLine2
*/
@Override
public void writeVisor(int animation, String sLine1, String sLine2) {
m_display.writeVisor(animation, sLine1, sLine2);
}
/**
*
* @param sLine1
* @param sLine2
*/
@Override
public void writeVisor(String sLine1, String sLine2) {
m_display.writeVisor(sLine1, sLine2);
}
/**
*
*/
@Override
public void clearVisor() {
m_display.clearVisor();
}
@Override
public boolean hasFeature(int feature) {
// for support of product_image only
//return(((DeviceDisplayAdvance.PRODUCT_IMAGE) & feature)>0);
// for support of product image and ticketlines list
return (((DeviceDisplayAdvance.PRODUCT_IMAGE | DeviceDisplayAdvance.TICKETLINES) & feature) > 0);
}
@Override
public boolean setProductImage(BufferedImage img) {
BufferedImage resizeImg = resize(img, m_jImage.getWidth(), m_jImage.getHeight());
m_jImage.setIcon(img == null ? null : new ImageIcon(resizeImg));
return true;
}
@Override
public boolean setTicketLines(JTicketLines ticketlinesPanel) {
setSize(967, 355 + 300);
m_jListContainer.setSize(700, 300);
m_jListContainer.add(ticketlinesPanel, java.awt.BorderLayout.CENTER);
return true;
}
private static BufferedImage resize(BufferedImage image, int width, int height) {
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TRANSLUCENT);
Graphics2D g2d = (Graphics2D) bi.createGraphics();
g2d.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
g2d.drawImage(image, 0, 0, width, height, null);
g2d.dispose();
return bi;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
m_jContainer = new javax.swing.JPanel();
m_jImage = new javax.swing.JLabel();
m_jListContainer = new javax.swing.JPanel();
setTitle(AppLocal.getIntString("Display.Window")); // NOI18N
m_jContainer.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
m_jContainer.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
m_jContainer.setPreferredSize(new java.awt.Dimension(210, 445));
m_jContainer.setLayout(new java.awt.BorderLayout());
m_jImage.setPreferredSize(new java.awt.Dimension(200, 200));
m_jContainer.add(m_jImage, java.awt.BorderLayout.LINE_END);
m_jContainer.add(m_jListContainer, java.awt.BorderLayout.PAGE_END);
getContentPane().add(m_jContainer, java.awt.BorderLayout.CENTER);
setSize(new java.awt.Dimension(967, 245));
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JPanel m_jContainer;
private javax.swing.JLabel m_jImage;
private javax.swing.JPanel m_jListContainer;
// End of variables declaration
}