allow painting of texture background.

cusax-fix
Yana Stamcheva 18 years ago
parent 195db71bad
commit 4751944d62

@ -28,6 +28,8 @@ dialPadHeight=150
dialPadHorizontalGap=5
dialPadVerticalGap=5
isTextureBackground=false
# branding
textStyle=resources/styles/defaultStyle.css

@ -182,6 +182,7 @@ TOOL_BAR_BACKGROUND=resources/images/impl/gui/common/toolbarBackground.png
MENU_BACKGROUND=resources/images/impl/gui/common/menuBackground.png
WINDOW_TITLE_BAR=resources/images/impl/gui/common/windowTitleBarBackground.png
WINDOW_TITLE_BAR_BG=resources/images/impl/gui/common/windowTitleBar.png
MAIN_WINDOW_BACKGROUND=
# systray
trayIcon=resources/images/impl/systray/systrayIcon.png

@ -0,0 +1,79 @@
package net.java.sip.communicator.impl.gui.customcontrols;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.utils.*;
public class ImageBackgroundViewport extends JViewport
{
private BufferedImage bgImage;
private TexturePaint texture;
private boolean isTextureBackground;
public ImageBackgroundViewport()
{
isTextureBackground = new Boolean(GuiActivator.getResources()
.getSettingsString("isTextureBackground")).booleanValue();
bgImage = ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
if (isTextureBackground)
{
Rectangle rect
= new Rectangle(0, 0,
bgImage.getWidth(null),
bgImage.getHeight(null));
texture = new TexturePaint(bgImage, rect);
}
}
public void paintComponent(Graphics g)
{
// do the superclass behavior first
super.paintComponent(g);
// paint the image
if (bgImage != null)
{
Graphics2D g2 = (Graphics2D) g;
if (isTextureBackground)
{
g2.setPaint(texture);
g2.fillRect(0, 0, this.getWidth(), this.getHeight());
}
else
{
g.setColor(new Color(
GuiActivator.getResources().getColor("contactListBackground")));
// paint the background with the choosen color
g.fillRect(0, 0, getWidth(), getHeight());
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}
}
public void setView(JComponent view)
{
view.setOpaque(false);
super.setView(view);
}
public Image getBackgroundImage()
{
return bgImage;
}
}

@ -91,7 +91,7 @@ public CallListPanel(MainFrame mainFrame)
*/
private void initPanels()
{
this.scrollPane.setViewport(new ScrollPaneBackground());
this.scrollPane.setViewport(new ImageBackgroundViewport());
this.scrollPane.getViewport().setView(callList);
this.searchPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
@ -411,53 +411,4 @@ public void pluginComponentRemoved(PluginComponentEvent event)
this.pluginPanel.remove((Component) c.getComponent());
}
private class ScrollPaneBackground extends JViewport
{
BufferedImage bgImage;
TexturePaint texture;
public ScrollPaneBackground()
{
bgImage = ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
// Rectangle rect
// = new Rectangle(0, 0,
// bgImage.getWidth(null),
// bgImage.getHeight(null));
// texture = new TexturePaint(bgImage, rect);
}
public void paintComponent(Graphics g)
{
// do the superclass behavior first
super.paintComponent(g);
g.setColor(new Color(
GuiActivator.getResources().getColor("contactListBackground")));
// paint the background with the choosen color
g.fillRect(0, 0, getWidth(), getHeight());
// paint the image
if (bgImage != null)
{
Graphics2D g2 = (Graphics2D) g;
// g2.setPaint(texture);
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}
public void setView(JComponent view)
{
view.setOpaque(false);
super.setView(view);
}
}
}

@ -419,30 +419,47 @@ public DialButton(Image iconImage)
public void paintComponent(Graphics g)
{
// do the superclass behavior first
// do the superclass behavior first
super.paintComponent(g);
g.setColor(new Color(
GuiActivator.getResources().getColor("contactListBackground")));
Graphics2D g2 = (Graphics2D) g;
// paint the background with the chosen color
g.fillRect(0, 0, getWidth(), getHeight());
boolean isTextureBackground = new Boolean(GuiActivator.getResources()
.getSettingsString("isTextureBackground")).booleanValue();
BufferedImage bgImage
= ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
// If we haven't specified a background image, we return.
if (bgImage == null)
return;
// paint the image
Graphics2D g2 = (Graphics2D) g;
if (bgImage != null)
{
if (isTextureBackground)
{
Rectangle rect
= new Rectangle(0, 0,
bgImage.getWidth(null),
bgImage.getHeight(null));
TexturePaint texture = new TexturePaint(bgImage, rect);
// g2.setPaint(texture);
g2.setPaint(texture);
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
g2.fillRect(0, 0, this.getWidth(), this.getHeight());
}
else
{
g.setColor(new Color(
GuiActivator.getResources()
.getColor("contactListBackground")));
// paint the background with the choosen color
g.fillRect(0, 0, getWidth(), getHeight());
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}
}
}

@ -21,6 +21,7 @@
import javax.swing.text.html.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.lookandfeel.*;
import net.java.sip.communicator.impl.gui.main.chat.history.*;
@ -70,12 +71,6 @@ public class ChatConversationPanel
private JSeparator copyLinkSeparator = new JSeparator();
/**
* The backgroud of the ScrollPane. Used to load the image to be displayed
* in the background.
*/
private ScrollPaneBackground scrollPaneBackground = new ScrollPaneBackground();
/*
* Tooltip on hyperlinks - JDK 1.5+
*
@ -128,12 +123,15 @@ public ChatConversationPanel(ChatConversationContainer chatContainer)
this.setWheelScrollingEnabled(true);
this.setViewport(this.scrollPaneBackground);
ImageBackgroundViewport imageViewport = new ImageBackgroundViewport();
this.setViewport(imageViewport);
// As the JComponent.setOpaque(false) function slows down the display
// speed, we only set it when a custom image for the background exists.
// If there is no custom background image, we simply skip the
// JComponent.setOpaque(false) function call.
if(this.scrollPaneBackground.getBackgroundImage() != null)
if(imageViewport.getBackgroundImage() != null)
{
this.chatEditorPane.setOpaque(false);
}
@ -1153,75 +1151,4 @@ private String processImgTags(String message, String contentType)
}
return processedMessage.toString();
}
private class ScrollPaneBackground extends JViewport
{
/**
* The BufferedImage of the background. May be null when no custom
* background is set.
*/
private BufferedImage bgImage;
private TexturePaint texture;
public ScrollPaneBackground()
{
bgImage = ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
// Rectangle rect
// = new Rectangle(0, 0,
// bgImage.getWidth(null),
// bgImage.getHeight(null));
// texture = new TexturePaint(bgImage, rect);
}
/**
* Returns the instance of the BufferedImage used for the background of
* the ScrollPane.
* @return The BufferedImage of the ScrollPane. NULL is returned when
* the image does not exists.
*/
public BufferedImage getBackgroundImage()
{
return this.bgImage;
}
public void paintComponent(Graphics g)
{
// do the superclass behavior first
super.paintComponent(g);
g.setColor(new Color(
GuiActivator.getResources().getColor("contactListBackground")));
// paint the background with the choosen color
g.fillRect(0, 0, getWidth(), getHeight());
// paint the image
if (bgImage != null)
{
Graphics2D g2 = (Graphics2D) g;
// g2.setPaint(texture);
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}
public void setView(JComponent view)
{
// As the JComponent.setOpaque(false) function slows down the display
// speed, we only set it when a custom image for the background exists.
// If there is no custom background image, we simply skip the
// JComponent.setOpaque(false) function call.
if(this.getBackgroundImage() != null)
{
view.setOpaque(false);
}
super.setView(view);
}
}
}

@ -13,6 +13,7 @@
import javax.swing.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.chat.*;
import net.java.sip.communicator.impl.gui.main.chat.conference.*;
@ -48,7 +49,7 @@ public ChatRoomsListPanel(MainFrame frame)
this.treePanel.add(chatRoomsList, BorderLayout.NORTH);
this.treePanel.setOpaque(false);
this.setViewport(new ScrollPaneBackground());
this.setViewport(new ImageBackgroundViewport());
this.getViewport().setView(treePanel);
this.setHorizontalScrollBarPolicy(
@ -116,53 +117,4 @@ else if(selectedValue instanceof ChatRoomWrapper)
}
}
}
private class ScrollPaneBackground extends JViewport
{
BufferedImage bgImage;
TexturePaint texture;
public ScrollPaneBackground()
{
bgImage = ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
// Rectangle rect
// = new Rectangle(0, 0,
// bgImage.getWidth(null),
// bgImage.getHeight(null));
// texture = new TexturePaint(bgImage, rect);
}
public void paintComponent(Graphics g)
{
// do the superclass behavior first
super.paintComponent(g);
g.setColor(new Color(
GuiActivator.getResources().getColor("contactListBackground")));
// paint the background with the choosen color
g.fillRect(0, 0, getWidth(), getHeight());
// paint the image
if (bgImage != null)
{
Graphics2D g2 = (Graphics2D) g;
// g2.setPaint(texture);
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}
public void setView(JComponent view)
{
view.setOpaque(false);
super.setView(view);
}
}
}

@ -16,6 +16,7 @@
import javax.swing.Timer;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.chat.*;
@ -66,7 +67,7 @@ public ContactListPanel(MainFrame mainFrame) {
this.treePanel.setOpaque(false);
this.setViewport(new ScrollPaneBackground());
this.setViewport(new ImageBackgroundViewport());
this.getViewport().setView(treePanel);
@ -618,53 +619,4 @@ else if (selectedValue instanceof MetaContactGroup) {
}
}
}
private class ScrollPaneBackground extends JViewport
{
BufferedImage bgImage;
TexturePaint texture;
public ScrollPaneBackground()
{
bgImage = ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
// Rectangle rect
// = new Rectangle(0, 0,
// bgImage.getWidth(null),
// bgImage.getHeight(null));
// texture = new TexturePaint(bgImage, rect);
}
public void paintComponent(Graphics g)
{
// do the superclass behavior first
super.paintComponent(g);
g.setColor(new Color(
GuiActivator.getResources().getColor("contactListBackground")));
// paint the background with the choosen color
g.fillRect(0, 0, getWidth(), getHeight());
// paint the image
if (bgImage != null)
{
Graphics2D g2 = (Graphics2D) g;
// g2.setPaint(texture);
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}
public void setView(JComponent view)
{
view.setOpaque(false);
super.setView(view);
}
}
}

Loading…
Cancel
Save