2013-01-17 53 views
0

我有一个名为ContentStream类......问题是,内部类AddRectancle想获得类吸气的信息GraphicBeginn ...我想的类ContentStream可以达到吸气至少吸气剂是公共... PLSE告诉我如何内部类共享属性信息

public class ContentStreamExt extends ContentStreamProcessor 

{ 

private Matrix graphicalMatrix; 

public ContentStreamProcessorExt(ExtListener extListener) 
{ 
    super(extListener); 
} 

private void enhanceAdditional() 
{ 
    GraphicBeginn beginnGraphic = new GraphicBeginn(); 

    super.register("a", beginnGraphic); 
    super.register("b", new AddRectangle(beginnGraphic)); 
} 

private static class AddRectangle(GrapicBeginn beginn) 
{ 
    // should get the info of uUx and uUy 
} 

private static class GraphicBeginn implements ContentOperator 
{ 
    private float uUx; 
    private float uUy; 

    public float getuUx() 
    { 
     return this.uUx; 
    } 

    public float getuUy() 
    { 
     return this.uUy; 
    } 
..... // the input for uUx and uuy will be created in a method 
} 
+0

我已经实例化GraphicBeginn的对象,我希望能得到和的uux有uUy,只是把它传递给AddRectangle (float x,float y) – Fendrix

回答

1

你给的代码有许多的问题,它不能正确作为另一个海报指出编译。它也出现在提供方法签名的同时还声明了一个名为“AddRectange”的类。这是一个类还是一个方法?你需要决定哪一个,它不可能是两个。这是我认为一个例子描述你想在一般意义上做什么:

public class SampleClass { 

public SampleClass() { 
} 

private void sampleClassMethod() { 
    A a = new A(); 
    a.acceptB(new B()); 
} 

private class A { 
    public void acceptB(B bObject) { 
     System.out.println(bObject.memberVar1); 
    } 

} 

private class B { 
    private int memberVar1 = 5; 
} 

} 
+0

谢谢...明白了......我的错:) – Fendrix

1

如果我正确理解你的问题,添加矩形类应该传递的一个实例图形开始,它可以调用公共getter。这种布线可以通过内容流类来完成。

通过以下方式在语法上是无效的

private static class AddRectangle(GrapicBeginn beginn) 
+0

ok ...但内容流类无法读取GraphicBeginn类的getter甚至公开 – Fendrix

+0

您要在哪里做? enhanceAdditional方法中的beginnGraphic实例有哪些可用的方法? – Scorpion

+0

只有一个私有方法在graphhicBegin中填充uUx和uUy ....在方法enhanceAdditional()中我尝试过... GraphicBeginn beginnGraphic = new GraphicBeginn(); ... float x = beginnraphic.getuUx; float y = beginnGraphic.getuUy;然后将它传递到AddRectangle(float x,float y) – Fendrix