本文整理汇总了Java中com.rapidminer.operator.ports.InputPorts类的典型用法代码示例。如果您正苦于以下问题:Java InputPorts类的具体用法?Java InputPorts怎么用?Java InputPorts使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InputPorts类属于com.rapidminer.operator.ports包,在下文中一共展示了InputPorts类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderConnectionsBackground
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
/**
* Draws the connections background (round pipe) for the given ports.
*
* @param inputPorts
* the input ports for which to draw connection backgrounds
* @param ports
* the output ports for which to draw connection backgrounds
* @param g2
* the graphics context to draw upon
*/
@SuppressWarnings("deprecation")
private void renderConnectionsBackground(final InputPorts inputPorts, final OutputPorts ports, final Graphics2D g2) {
for (int i = 0; i < ports.getNumberOfPorts(); i++) {
OutputPort from = ports.getPortByIndex(i);
Port to = from.getDestination();
if (to != null) {
Shape connector = ProcessDrawUtils.createConnector(from, to, model);
// the first paint can come before any of the operator register listeners fire
// thus we need to check the shape for null; subsequent calls will have a valid
// shape
if (connector == null) {
return;
}
g2.setColor(Color.WHITE);
if (from.getMetaData() instanceof CollectionMetaData) {
g2.setStroke(CONNECTION_COLLECTION_LINE_BACKGROUND_STROKE);
} else {
g2.setStroke(CONNECTION_LINE_BACKGROUND_STROKE);
}
g2.draw(connector);
}
}
}
示例2: ProcessContextEditor
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
/**
* Constructs an editor for the given process and edited context. See class comment to find out
* why you can pass in a context here.
*/
public ProcessContextEditor(Process process, ProcessContext alternativeContext) {
inputEditor = new RepositoryLocationsEditor<OutputPorts>(true, "context.input", "input");
outputEditor = new RepositoryLocationsEditor<InputPorts>(false, "context.output", "result");
macroEditor = new MacroEditor(true);
setLayout(new GridLayout(3, 1));
((GridLayout) getLayout()).setHgap(0);
((GridLayout) getLayout()).setVgap(10);
add(inputEditor);
add(outputEditor);
add(macroEditor);
setProcess(process, alternativeContext);
}
示例3: ProcessContextEditor
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
/** Constructs an editor for the given process and edited context. See class comment to find out why you can pass in
* a context here. */
public ProcessContextEditor(Process process, ProcessContext alternativeContext) {
inputEditor = new RepositoryLocationsEditor<OutputPorts>(true, "context.input", "input");
outputEditor = new RepositoryLocationsEditor<InputPorts>(false, "context.output", "result");
macroEditor = new MacroEditor(true);
setLayout(new GridLayout(3, 1));
((GridLayout) getLayout()).setHgap(0);
((GridLayout) getLayout()).setVgap(10);
inputEditor.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));
outputEditor.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));
add(inputEditor);
add(outputEditor);
add(macroEditor);
setProcess(process, alternativeContext);
}
示例4: autoWire
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void autoWire(CompatibilityLevel level, InputPorts inputPorts, LinkedList<OutputPort> readyOutputs)
throws PortException {
boolean success = false;
do {
Set<InputPort> complete = new HashSet<InputPort>();
for (InputPort in : inputPorts.getAllPorts()) {
success = false;
if (!in.isConnected() && !complete.contains(in)
&& in.getPorts().getOwner().getOperator().shouldAutoConnect(in)) {
Iterator<OutputPort> outIterator;
// TODO: Simon: Does the same in both cases. Check again.
if (in.simulatesStack()) {
outIterator = readyOutputs.descendingIterator();
} else {
outIterator = readyOutputs.descendingIterator();
}
while (outIterator.hasNext()) {
OutputPort outCandidate = outIterator.next();
// TODO: Remove shouldAutoConnect() in later versions
Operator owner = outCandidate.getPorts().getOwner().getOperator();
if (owner.shouldAutoConnect(outCandidate)) {
if (outCandidate.getMetaData() != null) {
if (in.isInputCompatible(outCandidate.getMetaData(), level)) {
readyOutputs.remove(outCandidate);
outCandidate.connectTo(in);
// we cannot continue with the remaining input ports
// since connecting may have triggered the creation of new input
// ports
// which would result in undefined behavior and a
// ConcurrentModificationException
success = true;
break;
}
}
}
}
// no port found.
complete.add(in);
if (success) {
break;
}
}
}
} while (success);
}
示例5: renderPortsBackground
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
/**
* Draws the given {@link Ports}.
*
* @param ports
* @param g2
*/
private void renderPortsBackground(final Ports<? extends Port> ports, final Graphics2D g2) {
boolean input = ports instanceof InputPorts;
g2.setStroke(LINE_STROKE);
for (Port port : ports.getAllPorts()) {
Point location = ProcessDrawUtils.createPortLocation(port, model);
// the first paint can come before any of the operator register listeners fire
// thus we need to check the location for null; subsequent calls will have a location
if (location == null) {
return;
}
double x = location.getX();
double y = location.getY();
Shape ellipseBoth;
int startAngle;
if (input) {
startAngle = 90;
ellipseBoth = new Arc2D.Double(new Rectangle2D.Double(x - PORT_SIZE_BACKGROUND / 2, y - PORT_SIZE_BACKGROUND
/ 2, PORT_SIZE_BACKGROUND, PORT_SIZE_BACKGROUND), startAngle, 180, Arc2D.PIE);
} else {
startAngle = 270;
ellipseBoth = new Arc2D.Double(new Rectangle2D.Double(x - PORT_SIZE_BACKGROUND / 2, y - PORT_SIZE_BACKGROUND
/ 2, PORT_SIZE_BACKGROUND, PORT_SIZE_BACKGROUND), startAngle, 180, Arc2D.PIE);
}
g2.setColor(Color.WHITE);
g2.fill(ellipseBoth);
}
}
示例6: renderPortsBackground
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
/**
* Draws the given {@link Ports}.
*
* @param ports
* @param g2
*/
private void renderPortsBackground(final Ports<? extends Port> ports, final Graphics2D g2) {
boolean input = ports instanceof InputPorts;
g2.setStroke(LINE_STROKE);
for (Port port : ports.getAllPorts()) {
Point location = ProcessDrawUtils.createPortLocation(port, model);
// the first paint can come before any of the operator register listeners fire
// thus we need to check the location for null; subsequent calls will have a location
if (location == null) {
return;
}
double x = location.getX();
double y = location.getY();
Shape ellipseBoth;
int startAngle;
if (input) {
startAngle = 90;
ellipseBoth = new Arc2D.Double(new Rectangle2D.Double(x - PORT_SIZE_BACKGROUND / 2,
y - PORT_SIZE_BACKGROUND / 2, PORT_SIZE_BACKGROUND, PORT_SIZE_BACKGROUND), startAngle, 180,
Arc2D.PIE);
} else {
startAngle = 270;
ellipseBoth = new Arc2D.Double(new Rectangle2D.Double(x - PORT_SIZE_BACKGROUND / 2,
y - PORT_SIZE_BACKGROUND / 2, PORT_SIZE_BACKGROUND, PORT_SIZE_BACKGROUND), startAngle, 180,
Arc2D.PIE);
}
g2.setColor(Color.WHITE);
g2.fill(ellipseBoth);
}
}
示例7: getInnerSinks
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
public InputPorts getInnerSinks() {
return innerInputPorts;
}
示例8: ManyToManyPassThroughRule
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
public ManyToManyPassThroughRule(InputPorts inputPorts, OutputPorts outputPorts) {
this.inputPorts = inputPorts;
this.outputPorts = outputPorts;
}
示例9: parseConnection
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
private void parseConnection(Element connectionElement, ExecutionUnit executionUnit) throws XMLException {
final OutputPorts outputPorts;
if (connectionElement.hasAttribute("from_op")) {
String fromOp = connectionElement.getAttribute("from_op");
Operator from = executionUnit.getOperatorByName(fromOp);
if (from == null) {
addMessage("<em class=\"error\">Unknown operator " + fromOp + " referenced in <code>from_op</code>.</em>");
return;
}
outputPorts = from.getOutputPorts();
} else {
outputPorts = executionUnit.getInnerSources();
}
String fromPort = connectionElement.getAttribute("from_port");
OutputPort out = outputPorts.getPortByName(fromPort);
if (out == null) {
addMessage("<em class=\"error\">The output port <var>" + fromPort + "</var> is unknown at operator <var>"
+ outputPorts.getOwner().getName() + "</var>.</em>");
return;
}
final InputPorts inputPorts;
if (connectionElement.hasAttribute("to_op")) {
String toOp = connectionElement.getAttribute("to_op");
Operator to = executionUnit.getOperatorByName(toOp);
if (to == null) {
addMessage("<em class=\"error\">Unknown operator " + toOp + " referenced in <code>to_op</code>.</em>");
return;
}
inputPorts = to.getInputPorts();
} else {
inputPorts = executionUnit.getInnerSinks();
}
String toPort = connectionElement.getAttribute("to_port");
InputPort in = inputPorts.getPortByName(toPort);
if (in == null) {
addMessage("<em class=\"error\">The input port <var>" + toPort + "</var> is unknown at operator <var>"
+ inputPorts.getOwner().getName() + "</var>.</em>");
return;
}
try {
out.connectTo(in);
} catch (PortException e) {
addMessage("<em class=\"error\">Faild to connect ports: " + e.getMessage() + "</var>.</em>");
}
}
示例10: apply
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
@Override
public String apply(final Operator operator, VersionNumber processVersion, final XMLImporter importer) {
if (operator.getClass().equals(SimpleOperatorChain.class)
&& (processVersion == null || processVersion.compareTo(APPLIES_UNTIL) < 0)) {
importer.doAfterAutoWire(new Runnable() {
@Override
public void run() {
OperatorChain chain = (OperatorChain) operator;
InputPorts inputs = chain.getInputPorts();
OutputPorts sources = chain.getSubprocess(0).getInnerSources();
InputPorts sinks = chain.getSubprocess(0).getInnerSinks();
OutputPorts outputs = chain.getOutputPorts();
boolean found;
do {
found = false;
for (int leftIndex = 0; leftIndex < sources.getNumberOfPorts(); leftIndex++) {
OutputPort source = sources.getPortByIndex(leftIndex);
if (!source.isConnected()) {
continue;
}
InputPort sink = source.getDestination();
if (sinks.getAllPorts().contains(sink)) {
int rightIndex = sinks.getAllPorts().indexOf(sink);
InputPort correspondingInput = inputs.getPortByIndex(leftIndex);
OutputPort correspondingOutput = outputs.getPortByIndex(rightIndex);
if (correspondingInput.isConnected() && correspondingOutput.isConnected()) {
OutputPort originalSource = correspondingInput.getSource();
InputPort finalDestination = correspondingOutput.getDestination();
originalSource.lock();
finalDestination.lock();
originalSource.disconnect();
source.disconnect();
correspondingOutput.disconnect();
originalSource.connectTo(finalDestination);
originalSource.unlock();
finalDestination.unlock();
found = true;
importer.addMessage("The connection from <code>" + source.getSpec()
+ "</code> to <code>" + sink
+ "</code> was replaced by the direct connection from <code>"
+ originalSource.getSpec() + "</code> to <code>" + finalDestination.getSpec()
+ "</code>.");
}
}
}
} while (found);
}
});
}
return null;
}
示例11: autoWire
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void autoWire(CompatibilityLevel level, InputPorts inputPorts, LinkedList<OutputPort> readyOutputs) throws PortException {
boolean success = false;
do {
Set<InputPort> complete = new HashSet<InputPort>();
for (InputPort in : inputPorts.getAllPorts()) {
success = false;
if (!in.isConnected() && !complete.contains(in) && in.getPorts().getOwner().getOperator().shouldAutoConnect(in)) {
Iterator<OutputPort> outIterator;
// TODO: Simon: Does the same in both cases. Check again.
if (in.simulatesStack()) {
outIterator = readyOutputs.descendingIterator();
} else {
outIterator = readyOutputs.descendingIterator();
}
while (outIterator.hasNext()) {
OutputPort outCandidate = outIterator.next();
// TODO: Remove shouldAutoConnect() in later versions
Operator owner = outCandidate.getPorts().getOwner().getOperator();
if (owner.shouldAutoConnect(outCandidate)) {
if (outCandidate.getMetaData() != null) {
if (in.isInputCompatible(outCandidate.getMetaData(), level)) {
readyOutputs.remove(outCandidate);
outCandidate.connectTo(in);
// we cannot continue with the remaining input ports
// since connecting may have triggered the creation of new input ports
// which would result in undefined behavior and a ConcurrentModificationException
success = true;
break;
}
}
}
}
// no port found.
complete.add(in);
if (success) {
break;
}
}
}
} while (success);
}
示例12: ManyToManyPassThroughRule
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
public ManyToManyPassThroughRule(InputPorts inputPorts, OutputPorts outputPorts) {
this.inputPorts = inputPorts;
this.outputPorts = outputPorts;
}
示例13: renderConnections
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
private void renderConnections(InputPorts inputPorts, OutputPorts ports, Graphics2D g) {
if (connectingPortSource != null && mousePositionRelativeToProcess != null && connectingPortSource instanceof InputPort && inputPorts.containsPort((InputPort) connectingPortSource)) {
g.setColor(ACTIVE_EDGE_COLOR);
Point2D toLoc = getPortLocation(connectingPortSource);
toLoc.setLocation(toLoc.getX() - PORT_SIZE, toLoc.getY());
g.draw(new Line2D.Double(toLoc.getX() + PORT_SIZE / 2, toLoc.getY(), mousePositionRelativeToProcess.getX(), mousePositionRelativeToProcess.getY()));
}
for (int i = 0; i < ports.getNumberOfPorts(); i++) {
OutputPort from = ports.getPortByIndex(i);
Port to = from.getDestination();
g.setColor(getColorFor(from, true, Color.LIGHT_GRAY));
if (to != null) {
if (from.getMetaData() instanceof CollectionMetaData) {
if (from == hoveringPort ||
to == hoveringPort ||
from == hoveringConnectionSource ||
from == selectedConnectionSource) {
g.setStroke(CONNECTION_COLLECTION_HIGHLIGHT_STROKE);
} else {
g.setStroke(CONNECTION_COLLECTION_LINE_STROKE);
}
g.draw(createConnector(from, to));
g.setColor(Color.white);
g.setStroke(LINE_STROKE);
g.draw(createConnector(from, to));
} else {
if (from == hoveringPort ||
to == hoveringPort ||
from == hoveringConnectionSource ||
from == selectedConnectionSource) {
g.setStroke(CONNECTION_HIGHLIGHT_STROKE);
} else {
g.setStroke(CONNECTION_LINE_STROKE);
}
// g.draw(new Line2D.Double(portLocations.get(from), portLocations.get(to)));
g.draw(createConnector(from, to));
}
}
if (connectingPortSource == from && mousePositionRelativeToProcess != null) {
g.setColor(ACTIVE_EDGE_COLOR);
Point2D fromLoc = getPortLocation(connectingPortSource);
g.draw(new Line2D.Double(fromLoc.getX() + PORT_SIZE / 2, fromLoc.getY(), mousePositionRelativeToProcess.getX(), mousePositionRelativeToProcess.getY()));
}
}
}
示例14: parseConnection
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
private void parseConnection(Element connectionElement, ExecutionUnit executionUnit) throws XMLException {
final OutputPorts outputPorts;
if (connectionElement.hasAttribute("from_op")) {
String fromOp = connectionElement.getAttribute("from_op");
Operator from = executionUnit.getOperatorByName(fromOp);
if (from == null) {
addMessage("<em class=\"error\">Unknown operator " + fromOp + " referenced in <code>from_op</code>.</em>");
return;
}
outputPorts = from.getOutputPorts();
} else {
outputPorts = executionUnit.getInnerSources();
}
String fromPort = connectionElement.getAttribute("from_port");
OutputPort out = outputPorts.getPortByName(fromPort);
if (out == null) {
addMessage("<em class=\"error\">The output port <var>" + fromPort + "</var> is unknown at operator <var>" + outputPorts.getOwner().getName() + "</var>.</em>");
return;
}
final InputPorts inputPorts;
if (connectionElement.hasAttribute("to_op")) {
String toOp = connectionElement.getAttribute("to_op");
Operator to = executionUnit.getOperatorByName(toOp);
if (to == null) {
addMessage("<em class=\"error\">Unknown operator " + toOp + " referenced in <code>to_op</code>.</em>");
return;
}
inputPorts = to.getInputPorts();
} else {
inputPorts = executionUnit.getInnerSinks();
}
String toPort = connectionElement.getAttribute("to_port");
InputPort in = inputPorts.getPortByName(toPort);
if (in == null) {
addMessage("<em class=\"error\">The input port <var>" + toPort + "</var> is unknown at operator <var>" + inputPorts.getOwner().getName() + "</var>.</em>");
return;
}
try {
out.connectTo(in);
} catch (PortException e) {
addMessage("<em class=\"error\">Faild to connect ports: " + e.getMessage() + "</var>.</em>");
// throw new XMLException(e.getMessage(), e);
}
}
示例15: apply
import com.rapidminer.operator.ports.InputPorts; //导入依赖的package包/类
@Override
public String apply(final Operator operator, VersionNumber processVersion, final XMLImporter importer) {
if (operator.getClass().equals(SimpleOperatorChain.class) && (processVersion == null || processVersion.compareTo(APPLIES_UNTIL) < 0)) {
importer.doAfterAutoWire(new Runnable() {
@Override
public void run() {
OperatorChain chain = (OperatorChain)operator;
InputPorts inputs = chain.getInputPorts();
OutputPorts sources = chain.getSubprocess(0).getInnerSources();
InputPorts sinks = chain.getSubprocess(0).getInnerSinks();
OutputPorts outputs = chain.getOutputPorts();
boolean found;
do {
found = false;
for (int leftIndex = 0; leftIndex < sources.getNumberOfPorts(); leftIndex++) {
OutputPort source = sources.getPortByIndex(leftIndex);
if (!source.isConnected()) {
continue;
}
InputPort sink = source.getDestination();
if (sinks.getAllPorts().contains(sink)) {
int rightIndex = sinks.getAllPorts().indexOf(sink);
InputPort correspondingInput = inputs.getPortByIndex(leftIndex);
OutputPort correspondingOutput = outputs.getPortByIndex(rightIndex);
if (correspondingInput.isConnected() && correspondingOutput.isConnected()) {
OutputPort originalSource = correspondingInput.getSource();
InputPort finalDestination = correspondingOutput.getDestination();
originalSource.lock();
finalDestination.lock();
originalSource.disconnect();
source.disconnect();
correspondingOutput.disconnect();
originalSource.connectTo(finalDestination);
originalSource.unlock();
finalDestination.unlock();
found = true;
importer.addMessage("The connection from <code>"+source.getSpec()+"</code> to <code>"+sink+"</code> was replaced by the direct connection from <code>"+originalSource.getSpec()+"</code> to <code>"+finalDestination.getSpec()+"</code>.");
}
}
}
} while (found);
}
});
}
return null;
}