当前位置: 首页>>代码示例>>Java>>正文


Java DragEvent类代码示例

本文整理汇总了Java中javafx.scene.input.DragEvent的典型用法代码示例。如果您正苦于以下问题:Java DragEvent类的具体用法?Java DragEvent怎么用?Java DragEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DragEvent类属于javafx.scene.input包,在下文中一共展示了DragEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkPlaceableTile

import javafx.scene.input.DragEvent; //导入依赖的package包/类
private boolean checkPlaceableTile (DragEvent e) {
    double halfHeight =
            (0.5) * myScale
                    .scale((mySprite.getBounds().getBottom() - mySprite.getBounds().getTop()));
    double halfWidth =
            (0.5) * myScale
                    .scale((mySprite.getBounds().getRight() - mySprite.getBounds().getLeft()));
    for (int r =
            (int) ((e.getY() - halfHeight) / levelView.getGrids()
                    .getCurrentBlockSize()); r < (int) ((e.getY() + halfHeight) /
                                                        levelView.getGrids()
                                                                .getCurrentBlockSize()); r++) {
        for (int c =
                (int) ((e.getX() - halfWidth) / levelView.getGrids()
                        .getCurrentBlockSize()); c < (int) ((e.getX() + halfWidth) / levelView
                                .getGrids().getCurrentBlockSize()); c++) {
            if (levelView.getLevel().getPlaceableTileManager().getPlaceableMap()
                    .getBitMap()[r][c]) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:25,代码来源:OnScreenSprite.java

示例2: checkPlaceableTile

import javafx.scene.input.DragEvent; //导入依赖的package包/类
private boolean checkPlaceableTile (DragEvent e) {
    double halfHeight =
            (0.5) * myController.getRatio()
                    .scale((getProfilable().getProfile().getImageHeight().doubleValue()));
    double halfWidth =
            (0.5) * myController.getRatio()
                    .scale((getProfilable().getProfile().getImageWidth().doubleValue()));
    for (int r =
            (int) ((e.getY() - halfHeight) /
                   myController.getRatio().scale(50)); r < (int) ((e.getY() + halfHeight) /
                                                                  myController.getRatio()
                                                                          .scale(50)); r++) {
        for (int c =
                (int) ((e.getX() - halfWidth) / myController.getRatio()
                        .scale(50)); c < (int) ((e.getX() + halfWidth) /
                                                myController.getRatio().scale(50)); c++) {
            if (myController.getLevel().getPlaceableTileManager().getPlaceableMap()
                    .getBitMap()[r][c]) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:25,代码来源:DraggableSpriteCell.java

示例3: mouseDragDropped

import javafx.scene.input.DragEvent; //导入依赖的package包/类
/**
 * Handle mouse drop events
 * 
 * @param e
 */
private void mouseDragDropped(final DragEvent e) {
	final Dragboard db = e.getDragboard();
	boolean success = false;

	if (db.hasFiles()) {
		success = true;
		boolean ctrlKeyPressed = popOver.isCtrlKeyPressed();
		boolean altKeyPressed = popOver.isAltKeyPressed();
		
		popOver.notifyDragEventListener(new DropzoneDragEvent(e, ctrlKeyPressed, altKeyPressed));

	}
	e.setDropCompleted(success);
	e.consume();
}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:21,代码来源:DropzonePopOverUI.java

示例4: AddTypeCommand

import javafx.scene.input.DragEvent; //导入依赖的package包/类
public AddTypeCommand(MomentExpVBox moment, DragEvent event, Main main) {
	this.event = event;
	typeName = event.getDragboard().getRtf();
	this.momentExpBorder = moment;
	this.main = main;

	for(Type t : main.getCurrentProject().getSchemaProjet().getTypes()){
		if(t.getName().equals(typeName)){
			type = (Classe) t;
		}
		else{
			setClassByName(t);
		}
	}
	setClassByName(main.getCurrentProject().getSchemaProjet());
	dup = duplicate(type);
}
 
开发者ID:coco35700,项目名称:uPMT,代码行数:18,代码来源:AddTypeCommand.java

示例5: handleDropped

import javafx.scene.input.DragEvent; //导入依赖的package包/类
@FXML
private void handleDropped(DragEvent event) {
    // ドラッグボードを取得
    Dragboard board = event.getDragboard();
    if (board.hasFiles()) {
        board.getFiles().stream().forEach((f) -> {
            if (f.isDirectory()) {
                List<String> filePathList = new ArrayList<>();
                getFileRecursion(filePathList, f.getAbsolutePath()).stream().filter(s -> isTextFile(s)).collect(Collectors.toList()).forEach(s -> fileList.getItems().add(new Label(s)));
            } else {
                if (isTextFile(f.getAbsolutePath()))
                    fileList.getItems().add(new Label(f.getAbsolutePath()));
            }
        });
        // ドロップ受け入れ
        event.setDropCompleted(true);
    } else {    // ファイル以外なら
        // ドロップ受け入れ拒否
        event.setDropCompleted(false);
    }
}
 
开发者ID:Khromium,项目名称:MakeSourceList4j,代码行数:22,代码来源:Controller.java

示例6: targetSetOnDragDropped

import javafx.scene.input.DragEvent; //导入依赖的package包/类
private void targetSetOnDragDropped(ScreenMap target, DragEvent e) {
	Dragboard db = e.getDragboard();
	boolean success = false;
	if (e.getDragboard().hasImage()) {
		String imageName = db.getString();
		Point2D point = target.sceneToLocal(e.getSceneX(), e.getSceneY());
		GamePoint gameCoords = new GamePoint(point.getX()/target.getScreenWidth(), point.getY()/target.getScreenHeight());
		for (Pair<String, Image> p : myScreenObjects.keySet()) {
			String iName = p.getKey();
			if (imageName.equals(iName)) {
				XStreamHandler xstream = new XStreamHandler();
				File tempSpriteFile = new File("data/tempSprites/tempSprite.xml");
				xstream.saveToFile(myScreenObjects.get(p), tempSpriteFile);
				SpriteMakerModel xmlSprite = (SpriteMakerModel) xstream.getAttributeFromFile(tempSpriteFile);
				xmlSprite.addComponent(new Position(gameCoords, 0)); //heading 0 because all sprites default to this
				myModel.addBackgroundTile(xmlSprite);
				break;
			}
		}
		success = true;
	}
	e.setDropCompleted(success);
	e.consume();
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:25,代码来源:ScreenObjectHolder.java

示例7: dragDropped

import javafx.scene.input.DragEvent; //导入依赖的package包/类
/**
 * Handle dropped files to editor.
 */
@FXThread
private void dragDropped(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);
    if (!canAccept(file)) return;

    handleFile(file);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:19,代码来源:ResourcePropertyEditorControl.java

示例8: dragOver

import javafx.scene.input.DragEvent; //导入依赖的package包/类
/**
 * Handle drag over.
 */
@FXThread
private void dragOver(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);
    if (!canAccept(file)) return;

    final Set<TransferMode> transferModes = dragboard.getTransferModes();
    final boolean isCopy = transferModes.contains(TransferMode.COPY);

    dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE);
    dragEvent.consume();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:ResourcePropertyEditorControl.java

示例9: handleDragDroppedEvent

import javafx.scene.input.DragEvent; //导入依赖的package包/类
/**
 * Handle dropped events.
 *
 * @param dragEvent the dropped event.
 */
@FXThread
private void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);

    if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) {
        return;
    }

    addMaterial(file.toPath());
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:24,代码来源:MaterialPropertyControl.java

示例10: handleDragOverEvent

import javafx.scene.input.DragEvent; //导入依赖的package包/类
/**
 * Handle drag over events.
 *
 * @param dragEvent the drag over event.
 */
@FXThread
private void handleDragOverEvent(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);

    if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) {
        return;
    }

    final Set<TransferMode> transferModes = dragboard.getTransferModes();
    final boolean isCopy = transferModes.contains(TransferMode.COPY);

    dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE);
    dragEvent.consume();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:28,代码来源:MaterialPropertyControl.java

示例11: onDragDropped

import javafx.scene.input.DragEvent; //导入依赖的package包/类
/**
 * Drag dropped to the file drop area.
 *
 * @param event
 *            Event data.
 */
public final void onDragDropped(final DragEvent event) throws IOException {
    boolean success = false;
    LOG.log(Level.FINE, "Drag dropped: " + event.getDragboard().getString());
    if (event.getDragboard().hasFiles()) {
        File file = event.getDragboard().getFiles().get(0);
        // Check if file has a valid extension
        if (file.getName().endsWith(".bin")) {
            openSimulationFile(file);
            success = true;
        } else {
            String message = "Incorrect extension of the opened file (required .bin)";
            Dialog.createExceptionDialog(message, new IllegalArgumentException(message));
        }
    }
    event.setDropCompleted(success);
    event.consume();
}
 
开发者ID:gim-,项目名称:particles-in-box-java,代码行数:24,代码来源:NewExperimentController.java

示例12: dragDropped

import javafx.scene.input.DragEvent; //导入依赖的package包/类
/**
 * Drag dropped action
 * 
 * @param event
 */
@FXML
public void dragDropped(DragEvent event) {		
   	try {
		loadConfig(event.getDragboard().getFiles().get(0));
	} catch (Exception e) {
		// TODO Auto-generated catch block
		Alert alert = new Alert(Alert.AlertType.ERROR);
		alert.setTitle("Import");
		alert.setHeaderText("Loading error");
		alert.setContentText(e.getMessage());
		alert.initModality(Modality.WINDOW_MODAL);
		alert.showAndWait();
		e.printStackTrace();
		return;
	}
      
	menuController.selectExerciseOverview();
   	event.setDropCompleted(true);
       event.consume();
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-null,代码行数:26,代码来源:ImportViewController.java

示例13: mouseDragOver

import javafx.scene.input.DragEvent; //导入依赖的package包/类
/**
 * Mouse dragover event.
 * 
 * @param event
 */
private void mouseDragOver (final DragEvent event) {
    if (event.getGestureSource() != contentPane &&
        (event.getDragboard().hasContent(VoogaFileFormat.getInstance()))) {
        VoogaFile content =
                (VoogaFile) event.getDragboard().getContent(VoogaFileFormat.getInstance());
        String color = "";
        if (content.getType() != VoogaFileType.FOLDER) {
            color = designboardProperties.getString("NonVoogaFileColor");
        }
        else {
            color = designboardProperties.getString("VoogaFileColor");
        }
        contentPane.setStyle(String
                .format(designboardProperties.getString("ContentPaneStringStyle"), color));
        event.acceptTransferModes(TransferMode.ANY);
    }
    else if (event.getDragboard().hasString()) {
        event.acceptTransferModes(TransferMode.ANY);
    }

    event.consume();
}
 
开发者ID:sjain28,项目名称:Game-Engine-Vooga,代码行数:28,代码来源:DesignBoard.java

示例14: addElement

import javafx.scene.input.DragEvent; //导入依赖的package包/类
/**
 * Method to add new element to the design board
 * 
 * @param file: file to add
 * @param event: drag and drop feature
 * @param archetype: archetype (if element has one)
 */
private void addElement (VoogaFile file, DragEvent event, String archetype) {
    String elementPath = file.getPath();
    if (elementPath != null) {
        try {
            if (ResourceDecipherer.isImage(elementPath)) {

                GameObjectBuilder builder = new GameObjectBuilder(elementManager);
                if (!archetype.isEmpty()) {
                    builder.setArchetype(archetype);
                }
                else {
                    builder.setDraggedImage(file.getPath());
                }
                builder.showAndWait();

            }
        }
        catch (VoogaException e) {
            VoogaAlert alert = new VoogaAlert(e.getMessage());
            alert.showAndWait();
        }
        elementManager.addElementId(elementPath);
    }
}
 
开发者ID:sjain28,项目名称:Game-Engine-Vooga,代码行数:32,代码来源:DesignBoard.java

示例15: onDagOver

import javafx.scene.input.DragEvent; //导入依赖的package包/类
/*********************************************************/
// 파일 드래그 드롭 처리.

/*
 * (non-Javadoc)
 * 
 * @see com.kyj.fx.voeditor.visual.component.text.AbstractDragDropHelper#
 * onDagOver(javafx.scene.input.DragEvent)
 */
@Override
public void onDagOver(DragEvent ev) {
	if (ev.isConsumed())
		return;

	if (ev.getDragboard().hasFiles()) {
		ev.acceptTransferModes(TransferMode.LINK);
		ev.consume();
	}

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:21,代码来源:CodeAreaFileDragDropHelper.java


注:本文中的javafx.scene.input.DragEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。