Search in sources :

Example 16 with Component

use of zipkin2.Component in project libSBOLj by SynBioDex.

the class ModuleDefinitionOutput method addSubComponents.

private static void addSubComponents(SBOLDocument document, ComponentDefinition componentDef, List<ComponentDefinition> subComponents) throws Exception {
    int i = 1;
    int start = 0;
    int end = 0;
    for (ComponentDefinition subComponent : subComponents) {
        Component component = componentDef.createComponent(subComponent.getDisplayId(), AccessType.PUBLIC, subComponent.getIdentity());
        start = end + 1;
        end = start + getSequenceLength(document, subComponent);
        SequenceAnnotation annotation = componentDef.createSequenceAnnotation("anno" + i, "location" + i, start, end, OrientationType.INLINE);
        annotation.setComponent(component.getIdentity());
        i++;
    }
}
Also used : SequenceAnnotation(org.sbolstandard.core2.SequenceAnnotation) Component(org.sbolstandard.core2.Component) FunctionalComponent(org.sbolstandard.core2.FunctionalComponent) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 17 with Component

use of zipkin2.Component in project libSBOLj by SynBioDex.

the class ModuleDefinitionOutput method getSequenceLength.

private static int getSequenceLength(SBOLDocument document, ComponentDefinition componentDef) throws Exception {
    if (componentDef.getSequences() != null && componentDef.getSequences().size() > 0) {
        Sequence sequence = componentDef.getSequences().iterator().next();
        return sequence.getElements().length();
    } else {
        int total = 0;
        for (SequenceAnnotation annotation : componentDef.getSequenceAnnotations()) {
            if (annotation.getComponent() != null) {
                Component component = annotation.getComponent();
                ComponentDefinition subComponentDef = component.getDefinition();
                total = total + getSequenceLength(document, subComponentDef);
            } else {
                throw new Exception("Can't get sequence length for an incomplete design");
            }
        }
        return total;
    }
}
Also used : SequenceAnnotation(org.sbolstandard.core2.SequenceAnnotation) Sequence(org.sbolstandard.core2.Sequence) Component(org.sbolstandard.core2.Component) FunctionalComponent(org.sbolstandard.core2.FunctionalComponent) SBOLValidationException(org.sbolstandard.core2.SBOLValidationException) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 18 with Component

use of zipkin2.Component in project libSBOLj by SynBioDex.

the class SequenceConstraintOutput method main.

public static void main(String[] args) throws Exception {
    String prURI = "http://partsregistry.org/";
    SBOLDocument document = new SBOLDocument();
    document.setDefaultURIprefix(prURI);
    document.setTypesInURIs(true);
    ComponentDefinition promoter = document.createComponentDefinition("BBa_K174004", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    promoter.addRole(SequenceOntology.PROMOTER);
    promoter.setName("pspac promoter");
    promoter.setDescription("LacI repressible promoter");
    ComponentDefinition constPromoter = document.createComponentDefinition("pspac", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    constPromoter.addRole(SequenceOntology.PROMOTER);
    constPromoter.setName("constitutive promoter");
    constPromoter.setDescription("pspac core promoter region");
    ComponentDefinition operator = document.createComponentDefinition("LacI_operator", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
    operator.addRole(SequenceOntology.OPERATOR);
    operator.setName("LacI operator");
    operator.setDescription("LacI binding site");
    Component promoterComponent = promoter.createComponent("promoter", AccessType.PUBLIC, constPromoter.getIdentity());
    Component operatorComponent = promoter.createComponent("operator", AccessType.PUBLIC, operator.getIdentity());
    promoter.createSequenceConstraint("r1", RestrictionType.PRECEDES, promoterComponent.getIdentity(), operatorComponent.getIdentity());
    SBOLWriter.write(document, (System.out));
}
Also used : SBOLDocument(org.sbolstandard.core2.SBOLDocument) Component(org.sbolstandard.core2.Component) URI(java.net.URI) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 19 with Component

use of zipkin2.Component in project powerbot by powerbot.

the class WidgetCloser method poll.

@Override
public void poll() {
    if (ctx.widgets.component(Constants.INFO_BANWARNING >> 16, Constants.INFO_BANWARNING & 0xffff).visible()) {
        final Component c = ctx.widgets.component(Constants.INFO_BANWARNING >> 16, Constants.INFO_BANWARNING_CLOSE);
        GoogleAnalytics.getInstance().pageview("scripts/0/login/warning", c.valid() ? c.text() : "");
    }
    final List<Integer> w = new ArrayList<Integer>();
    if (!ctx.properties.getProperty("widget.closer.disable", "").equals("true")) {
        for (final int e : ctx.bank.opened() ? Constants.WIDGETCLOSER_ACTIVE : Constants.WIDGETCLOSER_ITEMS) {
            w.add(e);
        }
    }
    if (!ctx.bot().allowTrades()) {
        for (final int e : Constants.WIDGETCLOSER_TRADE_ITEMS) {
            w.add(e);
        }
    }
    for (final int id : w) {
        final AtomicInteger a = attempts.get(id);
        if (a.get() >= 3) {
            continue;
        }
        final Component c = ctx.widgets.component(id >> 16, id & 0xffff);
        final Point p = c.screenPoint();
        if (c.visible() && c.click()) {
            if (Condition.wait(new Condition.Check() {

                @Override
                public boolean poll() {
                    return !c.visible() || !c.screenPoint().equals(p);
                }
            })) {
                a.set(0);
            } else {
                a.incrementAndGet();
            }
        }
    }
    for (final int id : Constants.WIDGETCLOSER_FATAL) {
        if (ctx.widgets.component(id >> 16, id & 0xffff).visible()) {
            ctx.controller.stop();
            return;
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Condition(org.powerbot.script.Condition) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) Point(java.awt.Point) Component(org.powerbot.script.rt6.Component) Point(java.awt.Point)

Example 20 with Component

use of zipkin2.Component in project powerbot by powerbot.

the class WidgetCloser method poll.

@Override
public void poll() {
    final List<Integer> w = new ArrayList<Integer>();
    if (!ctx.bot().allowTrades()) {
        for (final int e : Constants.WIDGETCLOSER_TRADE_ITEMS) {
            w.add(e);
        }
    }
    for (final int id : w) {
        final AtomicInteger a = attempts.get(id);
        if (a.get() >= 3) {
            continue;
        }
        final Component c = ctx.widgets.component(id >> 16, id & 0xffff);
        final Point p = c.screenPoint();
        if (c.visible() && c.click()) {
            if (Condition.wait(new Condition.Check() {

                @Override
                public boolean poll() {
                    return !c.visible() || !c.screenPoint().equals(p);
                }
            })) {
                a.set(0);
            } else {
                a.incrementAndGet();
            }
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Condition(org.powerbot.script.Condition) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) Point(java.awt.Point) Component(org.powerbot.script.rt4.Component) Point(java.awt.Point)

Aggregations

Test (org.junit.Test)7 Point (java.awt.Point)5 Component (org.powerbot.script.rt6.Component)5 Span (zipkin2.Span)5 Condition (org.powerbot.script.Condition)4 Component (org.sbolstandard.core2.Component)4 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)4 CheckResult (zipkin2.CheckResult)4 SequenceAnnotation (org.sbolstandard.core2.SequenceAnnotation)3 Font (java.awt.Font)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Component (org.powerbot.script.rt4.Component)2 Item (org.powerbot.script.rt6.Item)2 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)2 SBOLDocument (org.sbolstandard.core2.SBOLDocument)2 Sequence (org.sbolstandard.core2.Sequence)2 Component (zipkin2.Component)2 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)1