}   Font parent_font = FontUtil.getFont(c,parent); LineMetrics parent_metrics = null; if(!InlineLayout.isReplaced(node)) { if(!InlineLayout.isFloatedBlock(node,c)) { parent_metrics = parent_font.getLineMetrics(box.text, ((Graphics2D)c.getGraphics()).getFontRenderContext()); } else { parent_metrics = parent_font.getLineMetrics("Test", ((Graphics2D)c.getGraphics()).getFontRenderContext()); } } else { parent_metrics = parent_font.getLineMetrics("Test", ((Graphics2D)c.getGraphics()).getFontRenderContext());
public static void setupVerticalAlign(Context c, Node node, InlineBox box) {    //u.p("setup vertical align: node = " + node + " box = " + box);    // get the parent node for styling    Node parent = node.getParentNode();    //u.p("parent = " + parent);    Element elem = null;    if(node.getNodeType() == node.TEXT_NODE) {        parent = parent.getParentNode();        elem = (Element)node.getParentNode();    } else {        elem = (Element)node;    }    //u.p("parent = " + parent + " elem = " + elem);    //int parent_height = FontUtil.lineHeight(c,parent);    Font parent_font = FontUtil.getFont(c,parent);    LineMetrics parent_metrics = null;    if(!InlineLayout.isReplaced(node)) {        if(!InlineLayout.isFloatedBlock(node,c)) {            parent_metrics = parent_font.getLineMetrics(box.text, ((Graphics2D)c.getGraphics()).getFontRenderContext());        } else {            parent_metrics = parent_font.getLineMetrics("Test", ((Graphics2D)c.getGraphics()).getFontRenderContext());        }    } else {        parent_metrics = parent_font.getLineMetrics("Test", ((Graphics2D)c.getGraphics()).getFontRenderContext());    }    // the height of the font    float parent_height = parent_metrics.getHeight();    //u.p("parent strikethrough height = " + parent_metrics.getStrikethroughOffset());    String vertical_align = c.css.getStringProperty(elem,"vertical-align");    // set the height of the box to the height of the font    if(!InlineLayout.isReplaced(node)) {        box.height = FontUtil.lineHeight(c,node);    }    //u.p("vertical align = " + vertical_align);    if(vertical_align == null) {        vertical_align = "baseline";    }    box.baseline = 0;    // box.y is relative to the parent's baseline    box.y = 0;    // do nothing for 'baseline'    box.vset = true;    if(vertical_align.equals("baseline")) {        //noop    box.y = box.y;    }    // works okay i think    if(vertical_align.equals("super")) {        box.y = box.y + (int) (parent_metrics.getStrikethroughOffset()*2.0);    }    // works okay, i think    if(vertical_align.equals("sub")) {        box.y = box.y - (int) parent_metrics.getStrikethroughOffset();    }    // joshy: this is using the current baseline instead of the parent's baseline    // must fix    if(vertical_align.equals("text-top")) {        // the top of this text is equal to the top of the parent's text        // so we take the parent's height above the baseline and subtract our        // height above the baseline        box.y = -((int)parent_height - box.height);//(int) (parent_metrics.getStrikethroughOffset()*2.0);    }    // not implemented correctly yet    if(vertical_align.equals("text-bottom")) {        box.y = 0;    }    // not implemented correctly yet.    if(vertical_align.equals("top")) {        //u.p("before y = " + box.y);        //u.p("baseline = " + box.baseline);        box.y = box.y - box.baseline;//(int) (parent_metrics.getStrikethroughOffset()*2.0);        box.top_align = true;        //u.p("after y = " + box.y);        box.vset = false;    }    if(vertical_align.equals("bottom")) {        //u.p("before y = " + box.y);        //u.p("baseline = " + box.baseline);        box.y = box.y - box.baseline;//(int) (parent_metrics.getStrikethroughOffset()*2.0);        box.bottom_align = true;        //u.p("after y = " + box.y);        box.vset = false;    }    //u.p("returning box: " + box);}