23 package com.realtime.crossfire.jxclient.gui.log;
32 import java.awt.Color;
33 import java.awt.Graphics;
34 import java.awt.Graphics2D;
35 import java.awt.GraphicsEnvironment;
36 import java.awt.Image;
37 import java.awt.Toolkit;
38 import java.awt.datatransfer.Clipboard;
39 import java.awt.datatransfer.StringSelection;
40 import java.awt.datatransfer.Transferable;
41 import java.awt.event.ActionListener;
42 import java.awt.event.MouseEvent;
43 import java.awt.font.FontRenderContext;
44 import java.awt.image.BufferedImage;
45 import java.util.List;
46 import javax.swing.Timer;
47 import org.jetbrains.annotations.NotNull;
48 import org.jetbrains.annotations.Nullable;
102 private final Clipboard
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
109 private final Clipboard
selection = Toolkit.getDefaultToolkit().getSystemSelection();
149 @SuppressWarnings(
"FieldCanBeLocal")
153 public void stateChanged() {
161 public int getHeight() {
162 return Math.max(1,
GUILog.this.getHeight());
174 public void lineAdded() {
179 public void lineReplaced() {
184 public void linesRemoved(@NotNull
final List<Line> lines) {
185 final int endPosition = lines.get(lines.size()-1).getEndPosition();
213 final FontRenderContext context;
214 final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
215 final Graphics2D g = graphicsEnvironment.createGraphics(
new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB));
217 context = g.getFontRenderContext();
236 super.paintComponent(g);
238 g.setColor(
new Color(0, 0, 0, 0.0f));
239 g.fillRect(0, 0, getWidth(), getHeight());
250 if (y >= getHeight()) {
253 final int height = line.getHeight();
278 }
else if (distance > 0) {
315 public void setBounds(
final int x,
final int y,
final int width,
final int height) {
316 super.setBounds(x, y, width, height);
323 super.mousePressed(e);
325 if (
timer.isRunning()) {
333 super.mouseReleased(e);
335 if (
timer.isRunning()) {
343 super.mouseDragged(e);
347 if (!
timer.isRunning()) {
351 }
else if (e.getY() >= getHeight()) {
353 if (!
timer.isRunning()) {
359 if (
timer.isRunning()) {
367 super.mouseWheelMoved(wheelRotation);
450 if (this.selection !=
null) {
452 this.selection.setContents(
selection,
null);
453 }
catch (
final IllegalStateException ignored) {
458 }
catch (
final IllegalStateException ignored) {