001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets.plaf.html;
006:
007: import java.awt.*;
008: import java.util.*;
009: import java.io.*;
010:
011: import com.javelin.swinglets.*;
012: import com.javelin.swinglets.plaf.*;
013: import com.javelin.swinglets.theme.*;
014:
015: /**
016: * HTMLLabelUI defines a look and feel for default HTML.
017: * * @author Robin Sharp
018: */
019:
020: public class HTMLLabelUI extends HTMLComponentUI {
021: /**
022: * Render the UI on the PrintWriter
023: */
024: public void update(PrintWriter out, SComponent c) {
025: if (!c.isVisible())
026: return;
027:
028: Object cssClass = c.getClientProperty(CSS_CLASS);
029: if (cssClass != null) {
030: out.print("<DIV class=\"");
031: out.print(cssClass);
032: out.print("\">");
033: }
034:
035: SLabel label = (SLabel) c;
036:
037: if (label.getAnchor() != null) {
038: out.print("<A ");
039: HTMLUtility.setTag(out, "NAME", label.getAnchor());
040: out.print(">");
041: }
042:
043: if (label.getLink() != null && label.isEnabled()) {
044: out.print("<A HREF=\"");
045: if (label.getLink().getUrl() != null) {
046: out.print(label.getLink().getUrl());
047: } else {
048: out.print(label.getComponentUrl());
049: }
050: out.print("\"");
051:
052: if (label.getLink().getTarget() != null) {
053: if (label.getLink().getTarget().equals(SFrame.NEW))
054: out.print(" target=\"_blank\"");
055: else if (label.getLink().getTarget()
056: .equals(SFrame.SELF))
057: out.print(" target=\"_self\"");
058: else if (label.getLink().getTarget().equals(
059: SFrame.PARENT))
060: out.print(" target=\"_parent\"");
061: else if (label.getLink().getTarget().equals(SFrame.TOP))
062: out.print(" target=\"_top\"");
063: else {
064: out.print(" target=\"");
065: out.print(label.getLink().getTarget());
066: out.print("\"");
067: }
068: } else {
069: //out.print( " target=\"_self\"" );
070: }
071:
072: HTMLUtility.setMouseOverStatusText(out, c.getToolTipText());
073:
074: updateEvent(out, c);
075:
076: out.print(">");
077: }
078:
079: if (label.getTextAlignment() == SConstants.LEFT) {
080: HTMLUtility.updateText(out, label.getText(), label
081: .getFont(), label.getForeground(), label
082: .getHorizontalAlignment());
083: }
084:
085: if (label.getIcon() != null) {
086: label.getIcon().paint(out);
087: }
088:
089: if (label.getTextAlignment() == SConstants.RIGHT) {
090: HTMLUtility.updateText(out, label.getText(), label
091: .getFont(), label.getForeground(), label
092: .getHorizontalAlignment());
093: }
094:
095: if (label.getLink() != null && label.isEnabled())
096: out.print("</A>");
097:
098: if (cssClass != null) {
099: out.print("</DIV>");
100: }
101:
102: }
103:
104: }
|