Example usage for java.awt Image SCALE_FAST

List of usage examples for java.awt Image SCALE_FAST

Introduction

In this page you can find the example usage for java.awt Image SCALE_FAST.

Prototype

int SCALE_FAST

To view the source code for java.awt Image SCALE_FAST.

Click Source Link

Document

Choose an image-scaling algorithm that gives higher priority to scaling speed than smoothness of the scaled image.

Usage

From source file:ru.spbspu.viewer.DataView.java

/**
 * ? ?  ?/*from  www . ja v  a  2  s . c o  m*/
 */
void buildLimitedFullSpectrogram() {
    double limit = Double.valueOf(spinnerLimitFreq.getValue().toString()) * 2
            / Double.valueOf(spinnerDiscretization.getValue().toString());
    int cursorHeight = 19;
    fullSpectrogram.setSize(fullSpectrogram.getWidth(), jScrollPane2.getHeight() - cursorHeight);
    int spectHeigth = fullSpectrogram.getHeight() - cursorHeight / 2;
    int spectWidth = fullSpectrogram.getWidth() - SCALE_OF_SPECT - 8;
    Image spectrogram = _presenter.drawFullSpectrogram(limit, getWindowWidth(), sliderSpectrogram.getValue())
            .getScaledInstance(spectWidth, spectHeigth, Image.SCALE_FAST);
    labelForFullSpectr.setIcon(new ImageIcon(spectrogram));
    drawScaleFull();
}

From source file:org.pentaho.reporting.engine.classic.core.layout.process.text.RichTextImageProducer.java

public Image createImagePlaceholder(final RenderableReplacedContentBox content) {
    final long bcw = ProcessUtility.computeBlockContextWidth(content);
    final long width = ReplacedContentUtil.computeWidth(content);
    final long height = ReplacedContentUtil.computeHeight(content, bcw, width);

    final int w = (int) Math.max(1, StrictGeomUtility.toExternalValue(width));
    final int h = (int) Math.max(1, StrictGeomUtility.toExternalValue(height));

    if (metaData.isFeatureSupported(OutputProcessorFeature.DIRECT_RICHTEXT_RENDERING)) {
        final Image img = processRenderableReplacedContent(content.getStyleSheet(), width, height,
                content.getContent().getRawObject());
        if (img != null) {
            return img;
        }/*  ww w. j av a2s.c  o  m*/
        // preserve layout as much as possible.
        return new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR).getScaledInstance(w, h, Image.SCALE_FAST);
    }

    return new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR).getScaledInstance(w, h, Image.SCALE_FAST);
}

From source file:se.unlogic.hierarchy.foregroundmodules.imagegallery.GalleryModule.java

private void checkSettings(MutableSettingHandler mutableSettingHandler) {

    Integer thumbQuality = mutableSettingHandler.getInt("thumbQuality");

    if (thumbQuality != null && (thumbQuality == Image.SCALE_AREA_AVERAGING || thumbQuality == Image.SCALE_FAST
            || thumbQuality == Image.SCALE_REPLICATE || thumbQuality == Image.SCALE_SMOOTH)) {
        this.thumbQuality = thumbQuality;
    } else if (thumbQuality != null) {
        log.warn("Illegal thumbQuality setting value detected, " + thumbQuality + " in module "
                + this.moduleDescriptor);
    }//ww w .  j a  v  a2 s.c o m
}

From source file:simplealbum.mvc.picture.impl.SenderFile.java

public static void main(String[] args) throws IOException {
    SenderFile sf = new SenderFile();
    for (int i = 0; i < sf.toArray.length; i++) {
        File file = (File) sf.toArray[i];
        try {//ww  w.  j av  a  2 s .c  o m
            Image scaledInstance = ImageIO.read(file).getScaledInstance(36, 27, Image.SCALE_FAST);
            //                ImageIcon imageIcon = new ImageIcon(scaledInstance);
        } catch (Exception e) {
            System.out.println("Cahcead " + file.getName());
        }
        System.out.println("i " + i + " " + file.getName() + " size: " + file.length() + " M: "
                + Runtime.getRuntime().totalMemory());
    }
}

From source file:us.mn.state.dot.tms.client.camera.FTPStream.java

/** Create an image icon from image data */
protected ImageIcon createIcon(byte[] idata) {
    ImageIcon icon = new ImageIcon(idata);
    if (icon.getIconWidth() == size.width && icon.getIconHeight() == size.height)
        return icon;
    Image im = icon.getImage().getScaledInstance(size.width, size.height, Image.SCALE_FAST);
    return new ImageIcon(im);
}

From source file:utybo.branchingstorytree.swing.OpenBSTGUI.java

public OpenBSTGUI() {
    instance = this;
    UIManager.put("OptionPane.errorIcon", new ImageIcon(Icons.getImage("Cancel", 48)));
    UIManager.put("OptionPane.informationIcon", new ImageIcon(Icons.getImage("About", 48)));
    UIManager.put("OptionPane.questionIcon", new ImageIcon(Icons.getImage("Rename", 48)));
    UIManager.put("OptionPane.warningIcon", new ImageIcon(Icons.getImage("Error", 48)));

    BorderLayout borderLayout = new BorderLayout();
    borderLayout.setVgap(4);//from   www  .ja va 2  s.  co m
    getContentPane().setLayout(borderLayout);
    setIconImage(Icons.getImage("Logo", 48));
    setTitle("OpenBST " + OpenBST.VERSION);
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            boolean cancelled = false;
            int i = 0;
            for (Component c : container.getComponents()) {
                if (c instanceof StoryPanel) {
                    i++;
                } else if (c instanceof StoryEditor) {
                    container.setSelectedComponent(c);
                    if (((StoryEditor) c).askClose()) {
                        continue;
                    } else {
                        cancelled = true;
                        break;
                    }
                }
            }
            if (!cancelled) {
                if (i > 0) {
                    int j = Messagers.showConfirm(OpenBSTGUI.this,
                            "You are about to close " + i + " file(s). Are you sure you wish to exit OpenBST?",
                            Messagers.OPTIONS_YES_NO, Messagers.TYPE_WARNING, "Closing OpenBST");
                    if (j != Messagers.OPTION_YES)
                        cancelled = true;
                }
                if (!cancelled)
                    System.exit(0);
            }
        }

    });

    JMenuBar jmb = new JMenuBar();
    jmb.setBackground(OPENBST_BLUE);
    jmb.add(Box.createHorizontalGlue());
    jmb.add(createShortMenu());
    jmb.add(Box.createHorizontalGlue());
    this.setJMenuBar(jmb);

    addDarkModeCallback(b -> {
        jmb.setBackground(b ? OPENBST_BLUE.darker().darker() : OPENBST_BLUE);
    });

    container = new JTabbedPane();
    container.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    container.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (SwingUtilities.isMiddleMouseButton(e)) {
                final int i = container.indexAtLocation(e.getX(), e.getY());
                System.out.println(i);
                if (i > -1) {
                    Component c = container.getComponentAt(i);
                    if (c instanceof StoryPanel) {
                        container.setSelectedComponent(c);
                        ((StoryPanel) c).askClose();
                    } else if (c instanceof StoryEditor) {
                        container.setSelectedComponent(c);
                        ((StoryEditor) c).askClose();
                    }
                }
            }
        }
    });
    getContentPane().add(container, BorderLayout.CENTER);

    final JBackgroundPanel welcomeContentPanel = new JBackgroundPanel(Icons.getRandomBackground(),
            Image.SCALE_FAST);
    background = welcomeContentPanel;

    welcomeContentPanel.setLayout(new MigLayout("hidemode 2", "[grow,center]", "[][grow][]"));
    container.add(welcomeContentPanel);
    container.setTitleAt(0, Lang.get("welcome"));

    bannersPanel = new JPanel(new MigLayout("hidemode 2, gap 0px, fill, wrap 1, ins 0"));
    bannersPanel.setBackground(new Color(0, 0, 0, 0));
    welcomeContentPanel.add(bannersPanel, "cell 0 0,grow");

    if (OpenBST.VERSION.endsWith("u")) {
        JButton btnReportBugs = new JButton(Lang.get("welcome.reportbugs"));
        btnReportBugs.addActionListener(e -> {
            VisualsUtils.browse("https://github.com/utybo/BST/issues");
        });
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Experiment", 32)), Color.YELLOW,
                Lang.get("welcome.ontheedge"), btnReportBugs, false), "grow");
    } else if (OpenBST.VERSION.contains("SNAPSHOT")) {
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Experiment", 32)), Color.ORANGE,
                Lang.get("welcome.snapshot"), null, false), "grow");
    }

    if (System.getProperty("java.specification.version").equals("9")) {
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Attention", 32)),
                new Color(255, 50, 50), Lang.get("welcome.java9warning"), null, false), "grow");
    }
    if (System.getProperty("java.specification.version").equals("10")) {
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Attention", 32)),
                new Color(255, 50, 50), Lang.get("welcome.java10warning"), null, false), "grow");
    }

    JButton btnJoinDiscord = new JButton(Lang.get("openbst.discordjoin"));
    btnJoinDiscord.addActionListener(e -> {
        VisualsUtils.browse("https://discord.gg/6SVDCMM");
    });
    bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Discord", 48)), DISCORD_COLOR,
            Lang.get("openbst.discord"), btnJoinDiscord, true), "grow");

    JPanel panel = new JPanel();
    panel.setBackground(new Color(0, 0, 0, 0));
    welcomeContentPanel.add(panel, "flowx,cell 0 1,growx,aligny center");
    panel.setLayout(new MigLayout("", "[40%][][][][60%,growprio 50]", "[][grow]"));

    final JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogo", 48)));
    addDarkModeCallback(b -> lblOpenbst
            .setIcon(new ImageIcon(b ? Icons.getImage("FullLogoWhite", 48) : Icons.getImage("FullLogo", 48))));
    panel.add(lblOpenbst, "flowx,cell 0 0 1 2,alignx trailing,aligny center");

    JSeparator separator = new JSeparator();
    separator.setOrientation(SwingConstants.VERTICAL);
    panel.add(separator, "cell 2 0 1 2,growy");

    final JLabel lblWelcomeToOpenbst = new JLabel("<html>" + Lang.get("welcome.intro"));
    lblWelcomeToOpenbst.setMaximumSize(new Dimension(350, 999999));
    panel.add(lblWelcomeToOpenbst, "cell 4 0");

    Component horizontalStrut = Box.createHorizontalStrut(10);
    panel.add(horizontalStrut, "cell 1 1");

    Component horizontalStrut_1 = Box.createHorizontalStrut(10);
    panel.add(horizontalStrut_1, "cell 3 1");

    final JButton btnOpenAFile = new JButton(Lang.get("welcome.open"));
    panel.add(btnOpenAFile, "flowx,cell 4 1");
    btnOpenAFile.setIcon(new ImageIcon(Icons.getImage("Open", 40)));
    btnOpenAFile.addActionListener(e -> {
        openStory(VisualsUtils.askForFile(this, Lang.get("file.title")));
    });

    final JButton btnOpenEditor = new JButton(Lang.get("welcome.openeditor"));
    panel.add(btnOpenEditor, "cell 4 1");
    btnOpenEditor.setIcon(new ImageIcon(Icons.getImage("Edit Property", 40)));
    btnOpenEditor.addActionListener(e -> {
        openEditor(VisualsUtils.askForFile(this, Lang.get("file.title")));
    });

    JButton btnChangeBackground = new JButton(Lang.get("welcome.changebackground"),
            new ImageIcon(Icons.getImage("Change Theme", 16)));
    btnChangeBackground.addActionListener(e -> {
        BufferedImage prev = background.getImage();
        BufferedImage next;
        do {
            next = Icons.getRandomBackground();
        } while (prev == next);
        background.setImage(next);
    });
    welcomeContentPanel.add(btnChangeBackground, "flowx,cell 0 2,alignx left");

    JButton btnWelcomepixabay = new JButton(Lang.get("welcome.pixabay"),
            new ImageIcon(Icons.getImage("External Link", 16)));
    btnWelcomepixabay.addActionListener(e -> {
        VisualsUtils.browse("https://pixabay.com");

    });
    welcomeContentPanel.add(btnWelcomepixabay, "cell 0 2");

    JLabel creds = new JLabel(Lang.get("welcome.credits"));
    creds.setEnabled(false);
    welcomeContentPanel.add(creds, "cell 0 2, gapbefore 10px");

    setSize((int) (830 * Icons.getScale()), (int) (480 * Icons.getScale()));
    setLocationRelativeTo(null);
}